CentOS 6.x 7.x 安装 node.js 教程

版权声明:本文自撰,转载先跟我说一下比较好 https://blog.csdn.net/KimBing/article/details/88633158

CentOS 6.x 7.x 安装 node.js 教程

官方下载链接: https://nodejs.org/en/download/
Linux 各种版本系统的安装官方说明: https://github.com/nodesource/distributions/blob/master/README.md

CentOS 6 和 7 都是一样的安装方式

根据需要的版本执行相应的命令

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

执行完成之后再执行:

sudo yum install -y nodejs

就OK了

这是我的安装记录

###################################
#  第一步
###################################
[root@host config]# curl -sL https://rpm.nodesource.com/setup_11.x | bash -

## Installing the NodeSource Node.js 11.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 "el7-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_11.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.EpDGD31TUo' 'https://rpm.nodesource.com/pub_11.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.EpDGD31TUo'

## Cleaning up...

+ rm -f '/tmp/tmp.EpDGD31TUo'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `sudo yum install -y nodejs` to install Node.js 11.x and npm.
## You may also need development tools to build native addons:
     sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
     sudo yum install yarn
     
###################################
#  第二步
###################################

[root@host config]# sudo yum install -y nodejs
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: repos.lax.quadranet.com
 * elrepo-kernel: repos.lax-noc.com
 * extras: mirror.fileplanet.com
 * updates: mirror.fileplanet.com
 * webtatic: us-east.repo.webtatic.com
nodesource                                                                           | 2.5 kB  00:00:00     
nodesource/x86_64/primary_db                                                         |  22 kB  00:00:01     
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 2:11.12.0-1nodesource will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================
 Package             Arch                Version                              Repository               Size
============================================================================================================
Installing:
 nodejs              x86_64              2:11.12.0-1nodesource                nodesource               19 M

Transaction Summary
============================================================================================================
Install  1 Package

Total download size: 19 M
Installed size: 57 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/nodesource/packages/nodejs-11.12.0-1nodesource.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 34fa74dd: NOKEY
Public key for nodejs-11.12.0-1nodesource.x86_64.rpm is not installed
nodejs-11.12.0-1nodesource.x86_64.rpm                                                |  19 MB  00:00:02     
Retrieving key from file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Importing GPG key 0x34FA74DD:
 Userid     : "NodeSource <[email protected]>"
 Fingerprint: 2e55 207a 95d9 944b 0cc9 3261 5ddb e8d4 34fa 74dd
 Package    : nodesource-release-el7-1.noarch (installed)
 From       : /etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : 2:nodejs-11.12.0-1nodesource.x86_64                                                      1/1 
  Verifying  : 2:nodejs-11.12.0-1nodesource.x86_64                                                      1/1 

Installed:
  nodejs.x86_64 2:11.12.0-1nodesource                                                                       

Complete!

猜你喜欢

转载自blog.csdn.net/KimBing/article/details/88633158
今日推荐