npm 不支持 Node.js v12.18.3

新手上路,请多包涵

可以看到它已经被问了十几次,但到目前为止我找到的解决方案都没有对我有用。

我已经在我的 Windows 10 PC 上安装了最新版本的 Node.js (12.18.3),我正在尝试使用 npm 安装一个包。当我输入 npm -v 它返回 5.6.0,在我看来它已经过时了 - 但是当我尝试安装软件包或更新 npm 时,每次都会收到以下错误:

 npm WARN npm npm does not support Node.js v12.18.3
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, 9.
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:

我已经尝试完全卸载 Node.js,删除所有 node_modules 文件夹并在全新安装后重新启动计算机,但每次都是一样的。我也尝试过使用 npm install -g npmnpm install npm@latest -g 但同样,我得到了同样的错误。

这里有什么解决方案吗?

原文由 Amy 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 2.1k
2 个回答

我找到了解决方法!

首先你需要打开你的 cmd 行,然后使用“ npm install -g npm@latest ”你会得到这样的错误

C:\Users\KimeruLenovo>npm install -g npm@latest
npm WARN npm npm does not support Node.js v14.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, 9.
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\KimeruLenovo\AppData\Roaming\npm-cache_logs\2020-08 10T09_36_56_388Z-debug.log

转到可以找到调试日志的路径(此文件位于 npm-cache 文件夹中) C:\Users\KimeruLenovo\AppData\Roaming

删除 NPM 和 NPM-Cache 文件夹,但 不要 重新安装 node 。删除后返回您的命令行并重新使用命令“ npm install -g npm@latest

这应该可以解决问题:)

原文由 Laurent Luypaert 发布,翻译遵循 CC BY-SA 4.0 许可协议

我也有同样的问题,Windows 10 和 npm v6.4.1 并试图将节点从 v9 升级到 v12.18.3。

问题似乎是每当我尝试安装最新版本的节点时,npm 都没有升级,npm v6.4.1 只支持节点直到 v11(即使下载页面显示“最新 LTS 版本:12.18.3(包括npm 6.14.6)”: https ://nodejs.org/en/download/ )。

这个 Github 问题 让我找到了解决方案,即卸载节点(设置 -> 添加或删除程序),然后导航到 C:\Users\{User}\AppData\Roaming 并删除 npmnpm-chache 文件夹,最后再次安装节点(使用安装程序)。

原文由 bendikiv 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题