1.安装npm install -g npm-check-updates
可能会出现以下错误:
npm ERR! syscall mkdir
npm ERR! path D:\node\node_global\node_modules\npm-check-updates
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'D:\node\node_global\node_modules\npm-check-updates'
npm ERR! [Error: EPERM: operation not permitted, mkdir 'D:\node\node_global\node_modules\npm-check-updates'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'D:\\node\\node_global\\node_modules\\npm-check-updates'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\node\node_cache\_logs\2022-03-07T06_46_10_432Z-debug-0.log
以上错误的原因:
没有权限创建文件夹
解决方案:使用CMD命令,用管理员打开,在该目录下执行该命令
2.执行下面命令(显示当前目录下项目中所有新的依赖包)
ncu
3. 更新项目package文件
ncu -u
或者
npx npm-check-updates@next --upgrade
以上操作完毕之后,查看 package.json 文件,可以看到依赖包已经更新
关于npm-check-updates更多用法,请查看npm-check-updates - npm