我使用以下命令安装nodeJS版本8.x
1. sudo apt-get purge nodejs npm
2. curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
3. sudo apt-get install -y nodejs
当我运行命令时
node -v
它显示的是 v4.2.6,而不是最新的 8.x 版本。这是屏幕截图。
最佳答案
首次安装Node.js via apt-get
(例如 v8):
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
安装 Node.js 后,使用 npm 包 n切换到任何版本:
Simply execute
n <version>
to install a version of node. If<version>
has already been installed (vian
),n
will activate that version.
安装n
作为全局包并使用 n
安装最新版本的 Node.js:
npm i -g n
n latest
关于node.js - 乌类图14.04 : How to install specific version of nodeJS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48931001/