Reference:
How npm updates the latest dependent packages of a project
One-line command updates all npm dependent packages
npm upgrades dependent packages
批量升级有风险!!!升级需谨慎!!
Conventional package upgrade method
npm update (package)
Check project upgradable packages
method one
This command will check each installed dependency and compare the current version with the latest version in the npm registry. It prints out a table in the terminal outlining the available versions.
After viewing npm update manual update
- Current is the currently installed version.
- Wanted is the maximum version of the package in scope according to semver.
- Latest is the package version marked as latest in the npm registry.
npm outdated
Method 2 (one-click upgrade of all dependent packages)
npm-check-updates plugin address
- Red (display red) = major (major version, or large version)
- Cyan (shown in cyan) = minor (minor version)
- Green (display green) = patch (patch version)
1. Install the plugin globally
npm install -g npm-check-updates
2. Check for updates
npm-check-updates // 简写 ncu
3. Update the version in the package.json file
注意此命令是更新 package.json ,真正的依赖包还没有下载下来,所以需要删除 node_modules 重新 install
ncu -u
4. Execute npm install to automatically install the latest package
npm install
way three
The following command will check the upgradeable packages and list them (
可选择单个或多个进行更新
)
Select a package by blank space, switch with the up and down keys, Control + C to cancel the update, and press Enter to execute the update.
npm-check -u
Attached npm operation:
npm uninstall xxxx --save-dev //删除包及删除配置项
npm install xxx@version //安装指定版本
npm install //覆盖