【问题标题】:ERROR: npm is known not to run on Node.js v错误:已知 npm 不能在 Node.js v 上运行
【发布时间】:2018-10-30 01:24:06
【问题描述】:

每次我打开终端窗口时,我都会得到这个(甚至在输入任何内容之前):

ERROR: npm is known not to run on Node.js v4.1.2
Node.js 4 is supported but the specific version you're running has
a bug known to break npm. Please update to at least 4.7.0 to use this
version of npm. You can find the latest release of Node.js at https://nodejs.org/
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v4.1.2 --silent` to unset it.

我从未运行过 node 4 的版本,但无论如何我按照我在网上找到的一些非常彻底的步骤完全删除了 node.js,然后将其从网站重新安装到版本 8.11.2(node -v 给了我 v8. 11.2) 但警告仍然出现

直到我的 npm 在尝试使用 create-react 时开始严重出现问题之前,我从来没有过多关注它,通过 npm audit 向我发出大量安全警告,并且不让我更新到指定的模块版本。

我已经尝试了一切,重新安装 npm,重新安装节点等,我担心它现在会干扰我的应用程序。

【问题讨论】:

    标签: node.js macos npm terminal nvm


    【解决方案1】:

    (这里是 nvm 维护者)

    如果您可以让node 工作,而nvm current 不会说“无”或“系统”,那么您可以运行nvm install-latest-npm 以确保您拥有可以在您的节点上实际运行的最新版本的 npm版本。

    另外,节点 4.1.2 是 EOL - 如果这是您的系统版本,您可能需要完全卸载它。

    如果您仍然遇到问题,请在http://nvm.sh 上提出问题

    【讨论】:

    • 我遇到了同样的错误并尝试了nvm install-latest-npm,但这对我来说还不够。当我通过在 shell 中键入以下内容更改默认值时,问题已得到解决:nvm alias default v9.9.0
    猜你喜欢
    • 2022-08-09
    • 2018-03-03
    • 2018-07-06
    • 2022-07-24
    • 1970-01-01
    • 2021-10-23
    • 2015-01-23
    • 1970-01-01
    • 2020-11-08
    相关资源
    最近更新 更多