[npm] npm and package installation, update, delete, npm update is invalid

1. above sea level

Update

# 查看npm版本
npm --version
# 最新版
npm install -g npm
# 指定版本
npm install -g [email protected]

2 bags

installation

  • Global installation
npm install -g react
npm i -g react
  • Install locally to devdependencies
npm install --save-dev react
npm i -D react
  • Install locally to dependencies
npm install --save react
npm install react
npm i -S react
npm i react
  • Specify version
npm i [email protected]

delete

  • Delete global module
npm uninstall -g react
  • Delete module
npm uninstall react

Update

  • Check which modules can be updated
npm outdated

The feedback is as follows:

Package Current Wanted Latest Location
@babel/preset-env 7.12.10 7.12.11 7.12.11 pointsplus
@types/lodash 4.14.165 4.14.167 4.14.167 pointsplus
  • Update all modules
    Borrow npm-check-updates module
npm i -g npm-check-updates
# 使用
npm-check-updates
# 简写
ncu
# 更新全部模块
ncu -u

The results are as follows:

package description
@babel/preset-env ^7.12.10 → ^7.12.11
  • To update a single module,
    you can add -D, -S or -g at the back according to the scope of action
npm update @babel/preset-env

View

  • Globally installed packages
npm list -g
# 不包括子依赖
npm list -g --depth 0
  • Locally installed packages
npm list
# 不包括子依赖
npm list --depth 0

3. npm update is invalid

# TODO

Guess you like

Origin blog.csdn.net/u010682774/article/details/112652033
NPM