Ubuntu 和Debian以及CentOS这些内置源的NodeJS的版本和官方最新版差了个爷爷辈,所以需要安装新版的NodeJS要么去官方下包解压手动安装,要么找源进行安装。
本着方便的原则,当然是一键自动安装简单。因此发现了一个福利项目nodesource/distributions.
根据项目介绍.支持目前主流的Linux发行系统.
安装
RedHat系的系统包括 CentOS 和 Fedora,只需curl -sL https://rpm.nodesource.com/setup_8.x | bash -
后再执行yum install -y nodejs
即可.
以下是 Debian 系的安装.
Node.js v8.x:
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs
# Using Centos
curl -sL https://rpm.nodesource.com/setup_8.x | bash -
yum install -y nodejs
Node.js v7.x:
- NOTE: Debian Wheezy packages are NOT available for this release. Please reference running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_7.x | bash -
apt-get install -y nodejs
Node.js v6.x:
- NOTE: If you are using Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_6.x | bash -
apt-get install -y nodejs
Node.js v5.x:
- NOTE: If you are using Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_5.x | bash -
apt-get install -y nodejs
Node.js v4.x:
- NOTE: If you are using Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs