默认的,通过 yum install -g nodejs
安装 nodejs 为 0.1x 版本的。
如果需要其他版本,则需要指定 nodejs 源。
6.x
- curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
5.x
- curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
4.x
- curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
0.1x
- curl --silent --location https://rpm.nodesource.com/setup | bash -
指定 6.x 版本以后,如下提示,表示成功
- ## Installing the NodeSource Node.js 6.x repo...
- ## Inspecting system...
- + rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
- + uname -m
- ## Confirming "el6-x86_64" is supported...
- + curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_6.x/el/6/x86_64/nodesource-release-el6-1.noarch.rpm'
- ## Downloading release setup RPM...
- + mktemp
- + curl -sL -o '/tmp/tmp.CQ0Pv3MA10' 'https://rpm.nodesource.com/pub_6.x/el/6/x86_64/nodesource-release-el6-1.noarch.rpm'
- ## Installing release setup RPM...
- + rpm -i --nosignature --force '/tmp/tmp.CQ0Pv3MA10'
- ## Cleaning up...
- + rm -f '/tmp/tmp.CQ0Pv3MA10'
- ## Checking for existing installations...
- + rpm -qa 'node|npm' | grep -v nodesource
- ## Run `yum install -y nodejs` (as root) to install Node.js 6.x and npm.
- ## You may also need development tools to build native addons:
- ## `yum install -y gcc-c++ make`
然后执行全局安装
- yum install -y nodejs
完毕!