npm shortcuts

Wed, Feb 20, 2019 1-minute read

If you have always wondered what are all the npm commands and their shortcuts, here is a curated list of them

npm shortcuts

Photo by Sergi Kabrera on Unsplash


  1. Installing packages
  • regular
npm install <package-name>
  • shortcut
npm i <package-name>
  1. Installing a package glogally
npm install --global <package-name>
  • shortcut
npm i -g <package-name>
  1. Installing a package and saving it as a dependency
npm install --save <package-name>
  • shortcut
npm i -S <package-name>
  1. Installing a package and saving it as a dev dependency
npm install --save-dev <package-name>
  • shortcut
npm i -D <package-name>
  1. Initialize a new package instantly
npm init -y
  1. Running tests
  • regular
npm run test
npm test
  • shortcut
npm t
  1. Running before and after your tests
  • before your tests
npm run pretest
  • after your tests
npm run posttest
  1. list all the available scripts in package.json
npm run
  1. list all installed packages
  • local
npm ls --depth 0
  • global
npm ls -g --depth 0
  1. list all the environment variables avaiable to npm
npm run env
  1. Bumping your package version easily using semver
  • patch
npm version patch
v1.0.1
  • minor
npm version minor
v1.1.0
  • major
npm version major
v2.0.0