【问题标题】:Unable to install of latest version of nodejs无法安装最新版本的nodejs
【发布时间】:2018-10-16 22:20:06
【问题描述】:

我的 ubuntu 16.04 电脑中有 nodejs 版本 4.2.6。 我尝试使用命令sudo npm install -g n安装n,出现以下错误。

Node.js 4 is supported but the specific version you're running has

已知会破坏 npm 的错误。请更新到至少 4.7.0 才能使用它 npm 版本。你可以在https://nodejs.org/找到最新版本的 Node.js

我卸载了当前的nodejs,然后重新安装了它。但是每次安装4.2.6版本。我不明白为什么没有安装最新版本。我按照这个链接重新安装了我的nodejs enter link description here

我是否需要更新其他人才能拥有最新的 nodejs ?请指导我

【问题讨论】:

标签: node.js npm-install


【解决方案1】:

以下是要遵循的步骤:

  1. 首先清除缓存。
  2. 然后升级npm
  3. 如果是Node则安装稳定版
sudo npm cache clean -f
sudo npm install -g n
sudo n stable

如果还是不行

  1. 删除 NodeJs 和 Npm
  2. 安装节点
sudo apt remove nodejs npm
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

【讨论】:

  • $ sudo npm cache clean -f 错误:npm is known to not run on Node.js v4.2.6 Node.js 4 is supported but the specific version you are running with a bug known to break npm。请更新到至少 4.7.0 以使用此版本的 npm。您可以在 nodejs.org 找到最新版本的 Node.js,这是其显示的输出
  • 我更新了答案。请按照这些步骤操作一次。
【解决方案2】:

您可以通过添加本地 apt repo 来安装最新版本的 nodejs,如 official doc 中所述,

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

然后使用nnvm模块管理版本。

更新:您应该在安装新版本之前卸载旧版本

sudo apt-get purge nodejs
sudo apt-get autoremove

【讨论】:

  • 我非常认真地遵循了这些步骤,但每次安装相同的版本,即不是最新版本。它的 4.2.6 并声称它是最新版本。
  • 卸载再尝试安装,我也更新了答案
【解决方案3】:

你可以使用nvm并安装多个版本的node并打开node版本

这个链接可以帮助你

enter link description here

【讨论】:

    【解决方案4】:

    使用 NVM 管理所有节点版本

    【讨论】:

      猜你喜欢
      • 2022-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多