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
以下是我所关注的
安装
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")"
安装最新版本
node
(Linux 上的 Node.js):curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo apt-get install -y nodejs
使用最新的
nvm
:nvm use 14.0