nvm下升级npm版本

1 3445 error path C:UsersxxxAppDataRoaming
vmv12.18.3
pm.cmd
2 3446 error Refusing to delete C:UsersxxxAppDataRoaming
vmv12.18.3
pm.cmd: is outside C:UsersxxxAppDataRoaming
vmv12.18.3
ode_modules
pm and not a link
3 3447 error File exists: C:UsersxxxAppDataRoaming
vmv12.18.3
pm.cmd
4 3448 error Remove the existing file and try again, or run npm
5 3449 error with --force to overwrite files recklessly.
6 3450 verbose exit [ 1, true ]

直接npm install -g npm 报错 ,进入 C:UsersxxxAppDataRoaming vmv12.18.3 直接 

npm install npm

也一样报错

解决方案:

删除 C:UsersxxxAppDataRoaming vmv12.18.3 目录下的 npm npm.cmd npx npx.cmd

然后重命名   C:UsersxxxAppDataRoaming vmv12.18.3 ode_modules 下的npm文件夹(随便起个名 比如npm2)

// 1
cd C:UsersxxxAppDataRoaming vmv12.18.3 ode_modules pm2in

// 2
node npm-cli.js i -g npm

然后再把npm2文件夹删掉

npm --version // 7.24.0

npm就更新完了。 ps:谨慎更新

How to update npm? · Issue #1541 · nvm-sh/nvm · GitHub

原文地址:https://www.cnblogs.com/sphjy/p/15303832.html