Npm Commands

Git

NPM version

npm -v || npm --version

For help

npm || npm help

Creating package.json

npm init

Creating package.json with Default values

npm init --yes

Set default author

npm config set init-author-name "vishal ibitwar"

Set default License (while setting config is optional)

npm set init-license "MIT"

Check default values (here is author)

npm get init-author-name

Remove Default

npm config delete init-author-name

Install package and save as dependencies

npm install $package_name   --save

Install package and save as dev-dependencies

npm install $package_name   --save-dev
npm install --save-dev   $package_name

Install all dependencies (Regular as well as Dev)

npm install

Install only Regular dependencies

npm install --production

UnInstall package (dev-dependencies || regular dependencies)

npm uninstall $package_name --save-dev
npm un $package_name --save
npm remove $package_name --save
npm rm $package_name --save-dev

Install particular version

npm install $package_name@version
e.g. npm install loadash@4.17.3

Update package

npm update $package_name

About Versions

1.2.8

Major Version . Minor Version(new features) . Patch (bug fixes)
              major version can break the application
              minor version will not break the application
              Patch version will fixes the bugs can't break the application
                

4.3.6 will download the exact version

^4.3.6 will download the latest minor version

~4.3.6 will download the latest patch version

* will download the absolute latest major version

Install package Globally

npm install -g $package_name

To see where our global package installed

npm root -g

UnInstall globally installed package

npm remove -g $package_name

List the packages in the folder

npm list

List the package in the folder with depth-0

npm list --depth 0 (you can change depth as you want)