Common Node Package Manager (npm) commands.
# To interactively create a 'package.json' file:
npm init
# To download all the packages listed as dependencies in package.json:
npm install
# To download a specific version of a package and add it to the list of dependencies in 'package.json':
npm install <package_name>@<version>
# To download the latest version of a package and add it to the list of dev dependencies in 'package.json':
npm install <package_name> --save-dev
# To download the latest version of a package and install it globally:
npm install --global <package_name>
# To uninstall a package and remove it from the list of dependencies in 'package.json':
npm uninstall <package_name>
# To print a tree of locally installed dependencies:
npm list
# To list top-level globally installed packages:
npm list --global --depth=<0>
# ---
# To check a package for outdated dependencies:
npm outdated
# To update all outdated local packages:
npm update
# To update a package to the latest version:
npm install <package_name>@latest --save
# To update a dev package to the latest version:
npm install <package_name>@latest --save-dev
# To update all global packages by doing:
npm update -g
# To check for packages not declared in package.json:
npm prune
# To lock down your dependencies versions:
npm shrinkwrap
# To search for packages:
npm search <package_name>
# To see where modules go:
npm root
# To see where executables go:
npm bin
# To list installed packages:
npm ls