admin管理员组

文章数量:1530236

Windows 下npm升级方法

本来是尝试在windows下用命令升级nodejs,结果发现浪费了挺大劲,升级的是npm,已经记录的差不多了,有不舍得删,特此另起一篇记录吧。

1. 首先更新npm为淘宝源,实在是等不起
npm install -g cnpm --registry=https://registry.npm.taobao
2. 安装一个叫npm-windows-upgrade的包
cnpm install npm-windows-upgrade
3. 尝试执行npm-windows-upgrade
npm-windows-upgrade

提示内容的大意是没有权限,请一管理员身份运行

4. 以管理员身份运行powershell(win+x按键)

继续执行上述命令,提示如下内容

npm-windows-upgrade v6.0.1

Scripts cannot be executed on this system.
To fix, run the command below as Administrator in PowerShell and try again:
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force

大意是解决方法在终端中执行如下命令

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
5. 再次执行npm-windows-upgrade

显示内容如下

npm-windows-upgrade v6.0.1
? Which version do you want to install? (Use arrow keys)
> 6.9.0
  6.9.0-next.0
  6.8.0
  6.8.0-next.2
  6.8.0-next.1
  6.8.0-next.0
  6.7.0
(Move up and down to reveal more choices)

6. 再次执行npm-windows-upgrade -p -v latest

参考:
https://stackoverflow/questions/18412129/how-can-i-update-npm-on-windows
https://npm.taobao/

本文标签: 方法Windowsnpm