This page looks best with JavaScript enabled

Common NPM Commands

 ·  ☕ 2 min read

** By default, a command operates on the current directory environment. Adding the -g flag makes it apply globally instead.**

  • Upgrade npm
1
npm install npm -g
  • Show the current version
1
npm -v
  • Show the npm registry configuration
1
npm config get registry
  • Change the npm registry
1
2
npm config set registry http://registry.npm.taobao.org/
# npm config set registry https://registry.npmjs.org/
  • Specify an npm registry for one install only
1
 npm install [package name] --registry=https://registry.npm.taobao.org
  • Set a proxy
1
npm config set proxy http://proxy.example.com:8080
  • Show the proxy
1
npm config get proxy
  • Delete the proxy
1
npm config delete proxy
  • Show all configuration
1
npm config list
  • List installed packages
1
npm list
  • Install the packages described in packages.json
1
npm install
  • Install globally
1
npm install [package name] -g
  • Install into local dependencies
1
npm install [package name] --save
  • Install into local devDependencies
1
npm install [package name] --save-dev
  • Install the latest version
1
npm install [package name]@latest --save
  • Install a specific version
1
npm install [package name]@1.0.0 --save
  • Install a version greater than or equal to @1.0.0 and less than 2.2.0
1
npm install [package name]@">=2.0.0 <1.0.0" --save
  • Remove a global package
1
npm uninstall  [package name] -g
  • Remove a local package
1
npm uninstall  [package name]
  • List all locally updatable packages
1
npm outdated
  • Upgrade all packages
1
npm update

WeChat Official Account
WRITTEN BY
WeChat Official Account