如何在ubuntu 16.04上安装最新版本的nodejs?

时间:2017-11-06 17:30:37

标签: node.js npm install

我正在尝试使用npm在我的笔记本电脑上安装最新版本的nodejs。但每次我尝试安装时,都会收到此消息:

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 4.7.0 to use this
version of npm. You can find the latest release of Node.js at https://nodejs.org/

我已尝试过安装或升级nodejs和npm的所有方法,但我每次都收到此消息。另外,当我运行nodejs -v时,它显示了v4.2.6。

如何正确安装nodejs以便我可以使用它?

1 个答案:

答案 0 :(得分:2)

仔细阅读错误。支持Node.js 4,但您运行的特定版本已知会破坏npm的错误

你安装了一个nodejs版本,它不会让npm运行。所以你不能使用npm来更新nodejs。相反,您可以遵循nodejs安装指南"基于Debian和Ubuntu的Linux发行版"来自链接https://nodejs.org/en/download/package-manager/

for Node.js 6:

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

或者,对于Node.js 8:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
相关问题