npm help install
npm apihelp install
npm init
: interactively create package.jsonnpm set init-author-name
npm get init-author-name
npm config delete init-author-name
- Configs are saved in .npmrc
npm install lodash --save|-S
: install package and save it in package.jsonnpm uninstall lodash --save
: uninstall package and remove it in package.jsonnpm install lodash --save-dev|-D
: install package that is dev only not for prod and save it in package.jsonnpm list --depth 1 --global true --long true
npm i gulp -g
: install package globally for all projectsnpm list -g --depth 0
: check global packagesnpm i [email protected]
: install specific semantic version of the packagenpm i [email protected]
: install latest of 1.8 of the packagenpm i [email protected]
: install latest of 1.8 of the packagenpm i underscore@">=1.8 <2.0"
: install any version in the range of the packagenpm i [email protected] --save --save-exact
: put exact version in package.jsonnpm i
: install packages described in package.json- in package.json
- "*" or "x": the latest version
- "^1.7.1": at least 1.7.1
- "~1.7.1": the latest of the minor release 1.7
- "1.7.1": exact version 1.7.1
npm update
: easy update dependencies to the latest version
npm install https://github.com/...
: install from git reponpm i gist:<hash>
: install from gitsnpm i ../../hello-mars
: install from folder- www.npmjs.com: npm registry
npm search underscore
npm prune
: remove installed packages not in package.jsonnpm prune --production
: remove installed packages not in package.json productionnpm repo underscore
: go to the repo of the packagenpm i npm@latest -g
: upgrade npm. must be adminnpm test
: in package.json. Two important scripts:"scripts": { "test": "node test.js", "start": "node index.js" }