【问题标题】:Node JS - Not able to install node js version 8.9 or greater in ubuntu 16.04节点 JS - 无法在 ubuntu 16.04 中安装节点 js 版本 8.9 或更高版本
【发布时间】:2019-06-29 04:55:05
【问题描述】:

我尝试了各种方法来在我的操作系统上安装最新版本的 nodejs,但都没有成功。

最后总是安装 版本 v.4.2.6

当我运行以下命令时,它总是在我的终端屏幕截图中显示错误。
当前版本:
sudo apt-get install curl python-software-properties 卷曲-sLhttps://deb.nodesource.com/setup_11.x | sudo -E bash -

或 LTS 版本:
sudo apt-get install curl python-software-properties 卷曲-sLhttps://deb.nodesource.com/setup_10.x | sudo -E bash -

// 抛出错误 版本:


正在尝试执行节点 11 脚本:


上述脚本的o/p:

请指导我如何修复它。我已经关注了其他一些 stackoverflow 链接,但未能成功。

感谢您的帮助。

【问题讨论】:

  • 你试过sudo apt install nodejs吗?

标签: node.js express npm


【解决方案1】:

我建议卸载您当前的 NodeJS 版本并安装 nvm。 然后你就可以用 nvm 管理所有节点版本了。

方法一: 我按照这个链接,它是成功的: updating nodejs on ubuntu 16.04

方法二:

您可以跳过上面的链接并按照以下步骤操作:

使用节点版本管理器 (NVM):

按照说明安装它here

测试您的安装:

关闭当前终端,打开一个新终端,然后运行:

command -v nvm

使用它来安装任意数量的版本:

nvm install 8              # Install nodejs 8
nvm install --lts          # Install latest LTS (Long Term Support) version

列出已安装的版本:

nvm ls

使用特定版本:

nvm use 8                  # Use this version on this shell

设置默认值:

nvm alias default 8        # Default to nodejs 8 on this shell
nvm alias default node     # always use latest available as default nodejs for all shells

【讨论】:

    【解决方案2】:

    如果你安装了 npm -

    运行

    sudo npm cache clean -f
    sudo npm install -g n
    

    全局安装 n

    npm i -g n 
    

    然后使用 n 切换到最新的稳定节点版本

    n stable
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-13
      • 1970-01-01
      • 2019-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多