- Update npm:
npm install npm --global || npm i npm -g - New package:
npm init --yes || npm init -y - Scopes:
npm init --scope=myusernamenpm install @myusername/mypackagerequire('@myusername/mypackage') - Add dependencies:
npm install --save package-name || npm i -s package-name - Add devDependencies:
npm install --save-dev package-name || npm i -D package-name - Skip devDependencies:
npm install --production - Add bundled dependencies:
npm install --save --save-bundle package-name - Update dependencies:
npm outdated && npm update - Run scripts:
npm start npm stop npm restart npm test - Publish:
npm publish package-name - Publish private:
npm publish --access=restricted package-name - Publish public:
npm publish --access=public package-name - Unpublish:
npm unpublish package-name || npm unpublish package-name@version - Deprecate:
npm deprecate package-name || npm deprecate package-name@version - SemVer:
1.5.6 || Breaking.Feature.Fix || Major.Minor.Patch - Update package.json version:
npm version major || npm version minor || npm version patch - Remove npm errors from error log:
npm run [script] -s - Check the location of the npm command:
which npm - Check which files will output in your package:
npm pack --dry - Multiple packages simultaneously (symlink):
in package-a:
run npm link
in package-b (which requires package-a):
run npm link package-a
- dist-tags (distribution tags):
npm dist-tag add package-name@version
- Publish:
prepublish publish postpublish - Install:
preinstall install postinstall - Uninstall:
preuninstall uninstall postuninstall - Version:
preversion version postversion - Test:
pretest test posttest - Stop:
prestop stop poststop - Start:
prestart start poststart - Restart:
prerestart restart postrestart
Node security platform (nsp): consults a database of known securtiy vulnerablities when you run nsp check.
- To install:
npm install nsp -g - It can be useful if hooked to one of those lifecycle hooks above to prevent vulnerabilities in your packages