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
Photo by Sergi Kabrera on Unsplash
- Installing packages
- regular
npm install <package-name>
- shortcut
npm i <package-name>
- Installing a package glogally
npm install --global <package-name>
- shortcut
npm i -g <package-name>
- Installing a package and saving it as a dependency
npm install --save <package-name>
- shortcut
npm i -S <package-name>
- Installing a package and saving it as a dev dependency
npm install --save-dev <package-name>
- shortcut
npm i -D <package-name>
- Initialize a new package instantly
npm init -y
- Running tests
- regular
npm run test
npm test
- shortcut
npm t
- Running before and after your tests
- before your tests
npm run pretest
- after your tests
npm run posttest
- list all the available scripts in
package.json
npm run
- list all installed packages
- local
npm ls --depth 0
- global
npm ls -g --depth 0
- list all the environment variables avaiable to npm
npm run env
- 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