cheat:npm
---
tags: [ packaging ]
---
# Every command shown here can be used with the `-g` switch for global scope
# To install a package in the current directory:
npm install <package>
# To install a package, and save it in the `dependencies` section of `package.json`:
npm install --save <package>
# To install a package, and save it in the `devDependencies` section of `package.json`:
npm install --save-dev <package>
# To show outdated packages in the current directory:
npm outdated
# To update outdated packages:
npm update
# To update `npm` (will override the one shipped with Node.js):
npm install -g npm
# To uninstall a package:
npm uninstall <package>
# To set the `authToken` using env variable `NPM_TOKEN`:
npm config set //npm.intra/:_authToken=\${NPM_TOKEN}
tldr:npm
# npm
# JavaScript and Node.js package manager.
# Manage Node.js projects and their module dependencies.
# More information: <https://www.npmjs.com>.
# Interactively create a `package.json` file:
npm init
# Download all the packages listed as dependencies in package.json:
npm install
# Download a specific version of a package and add it to the list of dependencies in `package.json`:
npm install module_name@version
# Download a package and add it to the list of dev dependencies in `package.json`:
npm install module_name --save-dev
# Download a package and install it globally:
npm install --global module_name
# Uninstall a package and remove it from the list of dependencies in `package.json`:
npm uninstall module_name
# Print a tree of locally installed dependencies:
npm list
# List top-level globally installed modules:
npm list --global --depth=0
$
cheat.sh