我安装了最新的 nodejs 版本,但我也无法更新 npm(Windows)

时间:2021-01-28 11:22:58

标签: node.js windows npm cmd updates

我将 nodejs 更新到最新的稳定版本 v15.7.0。我的 npm 版本现在是 5.5.1 我尝试了命令 C:\Users\Asus>npm update -gC:\Users\Asus>npm install -g npm@latest 更新npm。但我每次都遇到这个错误:

npm WARN npm npm does not support Node.js v15.7.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! cb.apply is not a function

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Asus\AppData\Roaming\npm-cache\_logs\2021-01-28T11_03_53_376Z-debug.log

知道如何修复它吗?

3 个答案:

答案 0 :(得分:1)

根据 https://nodejs.org/en/download/(根据今天),它被称为 Latest LTS Version: 14.15.4 (includes npm 6.14.10)

由于 node 安装也包含 NPM,所以不需要单独安装。

最干净的方法是从你的机器上卸载 node 并重新安装它,这会自动让你兼容 NPM

答案 1 :(得分:0)

我找到了解决方案: https://github.com/nodejs/help/issues/2874#issuecomment-663661148

我删除了 Appdata 中的 npm 和 npm 缓存文件夹>漫游然后重新安装了 nodejs

答案 2 :(得分:0)

以管理员身份打开PowerShell并执行以下命令,

> Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
> npm install -g npm-windows-upgrade
> npm-windows-upgrade
相关问题