linux(centos7)使用yum命令安装nodejs 4.x,5.x教程

09-30 23:11:51   来源:shikezhi   评论: 点击:

如何在centos7上使用yum安装nodejs?本文将详细介绍如何在linux centos7上安装nodejs,步骤如下:
准备:使用curl下载并安装nodejs yum源
#nodejs 4.x yum源安装
curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
#nodejs 5.x yum源
curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
# nodejs 0.10 yum源
curl --silent --location https://rpm.nodesource.com/setup | bash -
 
本文将以4.x作为示例进行安装
 
1.获取4.x源
[root@test]# curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
 
您将会看到类似如下的信息:
## Installing the NodeSource Node.js v4.x LTS Argon 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 "el7-x86_64" is supported...
+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_4.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Downloading release setup RPM...
+ mktemp
+ curl -sL -o '/tmp/tmp.BgeTss5Mud' 'https://rpm.nodesource.com/pub_4.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Installing release setup RPM...
+ rpm -i --nosignature --force '/tmp/tmp.BgeTss5Mud'
## Cleaning up...
+ rm -f '/tmp/tmp.BgeTss5Mud'
## Checking for existing installations...
+ rpm -qa 'node|npm' | grep -v nodesource
XNode.js v4.x LTS Argon == XNode.js v5.x
## Run `yum install -y nodejs` (as root) to install Node.js v4.x LTS Argon and npm.
You may also need development tools to build native addons:
  `yum install -y gcc-c++ make`
 
 
如果您的系统上没安装gcc,需要先安装tcc
[root@test]# yum install -y gcc-c++ make
 
 
2.使用yum命令安装node
yum install -y nodejs
 
 
3.测试
[root@test]#  node -v
v4.6.0
[root@test]# npm -v
2.15.9
 
如果看到类似上面的版本信息说明nodejs已经安装成功!

相关热词搜索:centos7通过yum安装nodejs 4.x 5.x

上一篇:新入门node.js必须要知道的概念(必看篇) 下一篇:最后一页
分享到: 收藏