nodejs 已经是最新版本 (4.2.6~dfsg-1ubuntu4.2),无法安装

nodejs 已经是最新版本 (4.2.6~dfsg-1ubuntu4.2),无法安装

nodejs我在 Ubuntu 16.04 LTS 上安装新版本时遇到问题。

我尝试过以下命令:

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

这是其错误日志:https://justpaste.it/7j74u

然后我尝试:

sudo apt-get install -y nodejs

我得到了:

Reading package lists... 0%
Reading package lists... 100%
Reading package lists... Done
Building dependency tree... 0%
Building dependency tree... 0%
Building dependency tree... 50%
Building dependency tree... 50%
Building dependency tree... 91%
Building dependency tree       
Reading state information... 0%
Reading state information... 0%
Reading state information... Done
nodejs is already the newest version (4.2.6~dfsg-1ubuntu4.2).
0 upgraded, 0 newly installed, 0 to remove and 273 not upgraded.

然后,运行结果node -v显示:

command not found

如何node在我的 Ubuntu 上安装?

答案1

以下是我所关注的

  1. 安装nvm(从nvm GitHub 页面):

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
    export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
    
  2. 安装最新版本node(Linux 上的 Node.js):

    curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
    sudo apt-get install -y nodejs
    
  3. 使用最新的nvm

    nvm use 14.0
    

相关内容