Linux下根据订阅源安装最新NodeJS开发环境

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:

# 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:

# 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:

# 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:

# 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