前言
详细安装文档请转到:https://github.com/nodesource/distributions
安装
- Ubuntu 安装 nodejs
# 安装 Node.js v12.x:
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
# 安装 Node.js v11.x:
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
sudo apt-get install -y nodejs
- CentOS 安装 nodejs
# 安装 Node.js v12.x:
curl -sL https://rpm.nodesource.com/setup_12.x | bash -
sudo yum install -y nodejs
# 安装 Node.js v11.x:
curl -sL https://rpm.nodesource.com/setup_11.x | bash -
sudo yum install -y nodejs
注意
- 根据上面的安装命令 curl -sL https://rpm.nodesource.com/
setup_11.x
| bash -,安装不同的版本,区别在于setup_11.x版本号不同。 - 例如:Ubuntu 安装
Node.js v10.x
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs