我试了一下:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
...但这并没有起作用。
如何在Windows上做到这一点?
我试了一下:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
...但这并没有起作用。
如何在Windows上做到这一点?
当前回答
1. 安装最新的npm版本
npm install –g npm@latest
(你可以输入"npm -version "来检查)
2. 安装节点
a.通过以下路径安装节点新版本:https://nodejs.org/en/download/current/ 遵循默认选项 b.删除C:\Users\\AppData\Roaming\NPM c.删除c:\ users \\AppData\Roaming\npm-cache
(可选):
d.(删除当前项目文件夹中的node_modules文件夹) E. NPM缓存验证 F. NPM安装
其他回答
开始 搜索windows powershell 右键单击并以管理员身份运行 类型:where.exe节点(返回node.exe在系统中的路径。复制这个) wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile ' path - of - node. exe_where_you_copied_just_now ' 要检查它是否正常工作,请转到Git bash/Normal命令提示符并键入:node -v 您可以在这里找到节点的当前版本:https://nodejs.org/en/blog/release/
像一些人一样,我需要组合多个答案,我还需要设置一个代理。
这对任何人都适用。我有零愿望运行EXE文件或MSI文件..卸载/重新安装,或手动删除文件和文件夹。这就是1999年的情况:P
运行这个来更新NPM: 以管理员身份运行PowerShell npm i -g npm // 我不认为这段代码实际上升级了你下面的npm版本 Set-ExecutionPolicy unlimited -Scope CurrentUser -Force NPM install -g NPM -windows-upgrade npm-windows-upgrade (由“罗伯特”回答提供)
运行这个来更新Node.js:
wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\Program Files (x86)\nodejs\node.exe' (courtesy of BrunoLM answer)
如果你得到' wget:无法找到路径....的一部分**,见下文…向下滚动。阅读网络响应…它至少要通过防火墙/代理(如果你有一个或已经运行了代码,请通过…)
否则
您可能需要设置代理
npm config set proxy "http://proxy.yourcorp.com:811" (yes, use quotes)
2个可能的错误
It cannot find path of the path solution "where.exe node" (courtesy of Lonnie Best Answer) E.g. if Node.js is NOT living in "Program Files (x86)" perhaps with where.exe, it is living in 'C:\Program Files\nodejs\node.exe'. wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\Program Files\nodejs\node.exe' Now perhaps it tries to upgrade but you get another error, "node.exe is being used by another process." Close /shutdown other consoles .. command prompts and PowerShell windows, etc. Even if you're using npm in a command prompt, close it.
npm -v (3.10.8)
Node -v (v6.6.0)
完成了。我得到了我想要的版本。
这对我来说很好
以管理员身份运行命令提示符 导航到包含nodejs的文件夹(例如。C:\Program Files\ nodejs) 执行Powershell -ExecutionPolicy Unrestricted命令 运行npm-windows-upgrade 这将显示可供安装的版本列表。只需通过移动上/下键选择您想要的版本并按Enter。 这会更新你的npm 检查npm的当前版本 运行npm——version
命令提示符截图
你可以用下面的命令更新你的npm到最新的稳定版本:
npm install npm@latest -g
使用PowerShell来运行它。这个命令不需要windows管理员权限,你可以用npm -v来验证结果
我也面临着类似的问题。我遵循了下面提到的步骤,它对我很有效:
开始> Node.js 右键单击Node.js命令提示符 单击“以管理员身份运行” ping registry.npmjs.org NPM视图NPM版本号 cd % ProgramFiles % \ nodejs NPM安装npm@latest
NPM更新成功。早些时候,我正在尝试CMD,这是抛出错误。可能是路径问题,通过运行NodeJs命令提示符解决了。希望对你有用。试试这个。