错误:已知 npm 不能在 Node.js V4.2.6 上运行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46360567/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:29:26  来源:igfitidea点击:

Error: npm is known not to run on Node.js V4.2.6

node.jsnpm

提问by Martin Giuliani

how can I solve the following error? I use Ubuntu 16. When I run any npm command such as "npm run dev" I get this error:

如何解决以下错误?我使用 Ubuntu 16。当我运行任何 npm 命令(例如“npm run dev”)时,我收到此错误:

ERROR: npm is known not to run on Node.js v4.2.6 Node.js 4 is supported but the specific version you're running has a bug known to break npm. Please update to at least ${rel.min} to use this version of npm. You can find the latest release of Node.js at https://nodejs.org/

错误:已知 npm 不能在 Node.js v4.2.6 上运行 Node.js 4 受支持,但您正在运行的特定版本有一个已知会破坏 npm 的错误。请至少更新到 ${rel.min} 以使用此版本的 npm。你可以在https://nodejs.org/找到最新版本的 Node.js

回答by Liem Rodriguez

First, Uninstall completely nodejs and npm.

首先,完全卸载nodejs和npm。

sudo apt remove nodejs npm

Then, reinstall it over the link below:

然后,通过以下链接重新安装它:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

Refer: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

参考:https: //nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

回答by Kalana Demel

You can try downgrading the node version to switch from the bugged version using the following, upgrading also works if your app supports latest versions.

您可以尝试使用以下方法降级节点版本以从有漏洞的版本切换,如果您的应用支持最新版本,则升级也有效。

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash

nvm install 4.2.5

nvm use 4.2.5

//check with 
node -v

//To uninstall a node version 
nvm uninstall 4.2.6

回答by Avision

I just had this issue on Ubuntu 16. Use nto update to the latest version

我刚刚在 Ubuntu 16 上遇到了这个问题。使用n更新到最新版本

sudo n latest

That should settle it.

那应该解决它。

回答by DingLi

I download latest install package from https://nodejs.org/en/and reinstall it. Solve it!

我从https://nodejs.org/en/下载最新的安装包并重新安装。解决这个问题!

回答by zuko

You can also use NVM - I did this to solve the same problem.

您也可以使用 NVM - 我这样做是为了解决同样的问题。

first type

第一类

nvm ls-remoteto view the latest versions available,

nvm ls-remote查看可用的最新版本,

then

然后

nvm install [version](I used v8.7.0)

nvm install [version](我用的是 v8.7.0)

everything should be fine after that.

之后一切都会好起来的。

回答by ChuckZ

I had a similar problem but my project is part of a bigger system so neither switching to nvm instead of npm nor upgrading my version of Node.js were options.

我有一个类似的问题,但我的项目是一个更大系统的一部分,所以切换到 nvm 而不是 npm 或升级我的 Node.js 版本都是选项。

However, moving npm backwards to a previous version was an option. I found 4.6.1 worked without complaint.

但是,将 npm 向后移动到以前的版本是一种选择。我发现 4.6.1 毫无怨言地工作。

sudo npm install -g [email protected]

This version of npm did not complain.

这个版本的 npm 没有抱怨。

回答by amyd

I fixed the same issue with Ubuntu 16.04 by using following commands step by step.

我通过使用以下命令逐步修复了 Ubuntu 16.04 的相同问题。

Uninstall nodejs and install version 8.0

卸载 nodejs 并安装 8.0 版

$ sudo apt remove nodejs npm  
$ curl -o- 
https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
$ nvm install 8.0
$ nvm use 8.0
$ node -v
v8.0.0

回答by Muthinja Collins

Get latest release with

获取最新版本

$ nvm install node 

Then run the following

然后运行以下命令

$ nvm alias default stable_node_version