Cheat Sheets

npm

Created: 2017 May 19th

Updated: 2019 March 1st

Edit this page on GitHub

A list of terminal commands and flags to help me use npm

install package.json dependencies

1npm install

Shorthand

1# install
2npm i <package>
3# uninstall
4npm un <package>
5# update
6npm up <package>

List globally installed packages.

1npm list -g --depth=0

list available scripts to run

1npm run

update npm

1npm install -g npm@latest
2# using windows? Then use
3npm-windows-upgrade

flags

-S is the same as --save not needed in npm 5+ -D is the same as --save-dev

installed version

1npm list # for local packages

Uninstall global package

1npm -g uninstall <name> --save

Upgrade NPM on Windows

After trying several times to upgrade npm on Windows I found this whilst poking around.

1npm-windows-upgrade

Updating global packages

To update global packages individually you can use:

1npm update -g <package>

To see which packages need updating use:

1npm outdated -g --depth=0

dont rm -rf node_modules; npm install

Instead use:

1npm ci

It will have the same effect but be 2-3x faster ๐Ÿ‘Œ

Bump version number

1npm version patch
2# also | major | minor | patch