NPM cheatsheet
Table of contents
- see NPM cheatsheet
- Package management
- Generate a plain old package.json using legacy init:
- Alias for npm install
- Install everything in package.json
- Install everything in package.json, except devDependecies
- Install a package
- Install a package as devDependency
- Install a package with exact
- Bump the package version
- Bump the major package version by 1 (1.2.3 → 2.0.0)
- Bump the minor package version by 1 (1.2.3 → 1.3.0)
- Bump the patch package version by 1 (1.2.3 → 1.2.4)
- Listing
- Misc features
- Install names
- Updating
- NPM Ussage
see NPM cheatsheet
Package management
Generate a plain old package.json using legacy init:
npm init
Alias for npm install
npm i
Install everything in package.json
npm install
Install everything in package.json, except devDependecies
npm install --production
Install a package
npm install <package>
Install a package as devDependency
npm install --save-dev <package>
Install a package with exact
npm install --save-exact <package>
Bump the package version
npm version <version>
Bump the major package version by 1 (1.2.3 → 2.0.0)
npm version major
Bump the minor package version by 1 (1.2.3 → 1.3.0)
npm version minor
Bump the patch package version by 1 (1.2.3 → 1.2.4)
npm version patch
–save is the default as of npm@5. Previously, using npm install without –save doesn’t update package.json.
Listing
Lists the installed versions of all dependencies in this software
npm list
Lists the installed versions of all globally installed packages
npm list -g --depth 0
Lists the latest versions of all dependencies in this software
npm view
Lists only the dependencies in this software which are outdated
npm outdated
Misc features
Install names
Updating
NPM Ussage
Usage:
npm install install all the dependencies in your project
npm install <foo> add the <foo> dependency to your project
npm test run this project's tests
npm run <foo> run the script named <foo>
npm <command> -h quick help on <command>
npm -l display usage info for all commands
npm help <term> search for help on <term>
npm help npm more involved overview
All commands:
access, adduser, audit, bugs, cache, ci, completion,
config, dedupe, deprecate, diff, dist-tag, docs, doctor,
edit, exec, explain, explore, find-dupes, fund, get, help,
hook, init, install, install-ci-test, install-test, link,
ll, login, logout, ls, org, outdated, owner, pack, ping,
pkg, prefix, profile, prune, publish, query, rebuild, repo,
restart, root, run-script, search, set, shrinkwrap, star,
stars, start, stop, team, test, token, uninstall, unpublish,
unstar, update, version, view, whoami
Specify configs in the ini-formatted file:
/Users/cjrequena/.npmrc
or on the command line via: npm <command> --key=value
More configuration info: npm help config
Configuration fields: npm help 7 config