CentOS7 安装 Node.js

在 CentOS7 上安装 node.js,比较简单,做个记录。

CentOS7 安装 Node.js

Installation instructions using nvm


Installation instructions using rpm

NOTE: If you are using RHEL 6 or CentOS 6, you might want to read about running Node.js on older distros.

Run as root on RHEL, CentOS, CloudLinux or Fedora:

NodeJS 11.x

curl -sL https://rpm.nodesource.com/setup_11.x | bash -

NodeJS 10.x

curl -sL https://rpm.nodesource.com/setup_10.x | bash -

NodeJS 8.x

curl -sL https://rpm.nodesource.com/setup_8.x | bash -

NodeJS 6.x

curl -sL https://rpm.nodesource.com/setup_6.x | bash -

Optional: install build tools

To compile and install native addons from npm you may also need to install build tools:

yum install gcc-c++ make
# or: yum groupinstall 'Development Tools'

Then install:

sudo yum -y install nodejs