Package management

CommandDescription
npm iAlias for npm install
npm installInstall everything in package.json
npm install --productionInstall everything in package.json, except devDependecies

Adding packages

CommandDescription
npm install lodashInstall a package
npm install --save-dev lodashInstall as devDependency
npm install --save-exact lodashInstall with exact

Listing

CommandDescription
npm listLists the installed versions of all dependencies in this software
npm list -gLists the installed versions of all globally installed packages
npm view lodashShows registry info for a package
npm outdatedLists only the dependencies in this software which are outdated
npm auditLists known vulnerabilities in the project

Updating

CommandDescription
npm updateUpdate production packages
npm update --devUpdate dev packages
npm update -gUpdate global packages
npm update lodashUpdate a package

Removing

CommandDescription
npm rm lodashRemove package production packages

More features

Install names

CommandDescription
npm i saxNPM package
npm i sax@latestSpecify tag latest
npm i sax@3.0.0Specify version 3.0.0
npm i sax@">=1 <2.0"Specify version range
npm i @org/saxScoped NPM package
npm i user/repoGitHub
npm i user/repo#masterGitHub
npm i github:user/repoGitHub
npm i gitlab:user/repoGitLab
npm i /path/to/repoAbsolute path
npm i ./archive.tgzTarball
npm i https://site.com/archive.tgzTarball via HTTP

Bumping versions

CommandDescription
npm version 1.2.3Bump the package version to 1.2.3
npm version majorBump the major package version by 1 (1.2.3 → 2.0.0)
npm version minorBump the minor package version by 1 (1.2.3 → 1.3.0)
npm version patchBump the patch package version by 1 (1.2.3 → 1.2.4)

Misc features

# Add someone as an owner
npm owner add USERNAME PACKAGENAME
# list packages
npm ls
# Adds warning to those that install a package of old versions
npm deprecate PACKAGE@"< 0.2.0" "critical bug fixed in v0.2.0"
# update all packages, or selected packages
npm update [-g] PACKAGE
# Check for outdated packages
npm outdated [PACKAGE]
# Check the environment and cache
npm doctor
0 Comments for this cheatsheet. Write yours!