Useful NPM Commands


To identify the Node JS Version
node -v

To identify the NPM version
npm -v

Get the help
npm help

npm install -h

Get the help, How to update the npm
npm help-search update


init
---------------------
npm init
npm init --yes

npm config set init-author-name "Simon"
npm set init-license "SIM"

npm config get init-author-name
npm get init-license

npm config delete init-author-name
npm delete init-license

npm install moment
npm install moment --save (going to add dependency @package.json file)
npm install lodash --save-dev (going to add dev dependency @package.json file)

npm uninstall moment
npm uninstall moment --save (going to remove dependency)
npm uninstall lodash --save-dev (going to remove dependency)

npm install moment -g (install globally)
npm uninstall moment -g (uninstall globally)

the below command to use uninstall the package names
--------------------------------------------------------
npm install moment -g
npm remove moment -g
npm rm moment -g
npm un moment -g

npm list
npm list --depth 1 (immediate first level dependency)
npm list --depth 0 (nothing )

npm list --global true --depth 0

npm install lodash@3.3.0 --save (major and minor and patch)
npm install lodash@4.14 --save (major and minor version and latest patch version)
npm install lodash@4.14 --save (only major version)

 "moment": "^2.20.1" (^ means minor version)
 "moment": "~2.20.1" (~ means it's not upgrade major and minor version)
 "moment": "2.20.1" (exact version)
 "moment": "*" (* means latest)

npm update lodash --save
npm update --dev --save-dev
npm update
npm update -g
npm update -g gulp

npm install npm@latest -g

npm list --depth 0
npm prune

npm init -y
npm i lodash (install)
npm i lodash -S (upper case S)
npm i moment -D

https://docs.npmjs.com/misc/config

Comments