CentOS 中安装 Nodejs

root权限下运行该命令:

curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -

================================================================================

                          DEPRECATION WARNING                            

Node.js 8.x LTS Carbon is no longer actively supported!

You will not receive security or critical stability updates for this version.

You should migrate to a supported version of Node.js as soon as possible.
Use the installation script that corresponds to the version of Node.js you
wish to install. e.g.

  • https://deb.nodesource.com/setup_10.x — Node.js v10 LTS "Dubnium" (recommended)
  • https://deb.nodesource.com/setup_12.x — Node.js v12 LTS "Erbium"

Please see https://github.com/nodejs/Release for details about which
version may be appropriate for you.

The NodeSource Node.js distributions repository contains
information both about supported versions of Node.js and supported Linux
distributions. To learn more about usage, see the repository:
https://github.com/nodesource/distributions

================================================================================

Continuing in 20 seconds ...

Installing the NodeSource Node.js 8.x LTS Carbon 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_8.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

Downloading release setup RPM...

  • mktemp
  • curl -sL -o '/tmp/tmp.nRIV3DYJMN' 'https://rpm.nodesource.com/pub_8.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

Installing release setup RPM...

  • rpm -i --nosignature --force '/tmp/tmp.nRIV3DYJMN'

Cleaning up...

  • rm -f '/tmp/tmp.nRIV3DYJMN'

Checking for existing installations...

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

Run sudo yum install -y nodejs to install Node.js 8.x LTS Carbon 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@centos-linux-e wqching]# rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
centos-release-7-8.2003.0.el7.centos.x86_64
[root@centos-linux-e wqching]# uname -m
x86_64
[root@centos-linux-e wqching]# curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_8.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
[root@centos-linux-e wqching]# mktemp
/tmp/tmp.JDhvrm2GSJ
[root@centos-linux-e wqching]# curl -sL -o '/tmp/tmp.nRIV3DYJMN' 'https://rpm.nodesource.com/pub_8.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
[root@centos-linux-e wqching]# rpm -i --nosignature --force '/tmp/tmp.nRIV3DYJMN'
[root@centos-linux-e wqching]# rm -f '/tmp/tmp.nRIV3DYJMN'
[root@centos-linux-e wqching]# rpm -qa 'node|npm' | grep -v nodesource
[root@centos-linux-e wqching]# sudo yum install -y nodejs
Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 3077.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 48 M RSS (1.4 GB VSZ)
Started: Thu May 14 22:19:20 2020 - 00:28 ago
State : Sleeping, pid: 3077
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 264 M RSS (1.6 GB VSZ)
Started: Thu May 14 22:19:20 2020 - 00:30 ago
State : Running, pid: 3077
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 277 M RSS (1.6 GB VSZ)
Started: Thu May 14 22:19:20 2020 - 00:32 ago
State : Sleeping, pid: 3077
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 277 M RSS (1.6 GB VSZ)
Started: Thu May 14 22:19:20 2020 - 00:34 ago
State : Sleeping, pid: 3077
Loading mirror speeds from cached hostfile

  • base: ftp.iij.ad.jp
  • centos-sclo-rh: mirrors.ustc.edu.cn
  • centos-sclo-sclo: mirrors.ustc.edu.cn
  • epel: epel.mirror.angkasa.id
  • extras: mirror.vodien.com
  • remi-safe: mirrors.tuna.tsinghua.edu.cn
  • updates: ftp.iij.ad.jp
    Resolving Dependencies
    --> Running transaction check
    ---> Package nodejs.x86_64 2:8.17.0-1nodesource will be installed
    --> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================
Installing:
nodejs x86_64 2:8.17.0-1nodesource nodesource 18 M

Transaction Summary

Install 1 Package

Total download size: 18 M
Installed size: 55 M
Downloading packages:
nodejs-8.17.0-1nodesource.x86_64.rpm | 18 MB 00:03:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 2:nodejs-8.17.0-1nodesource.x86_64 1/1
Verifying : 2:nodejs-8.17.0-1nodesource.x86_64 1/1

Installed:
nodejs.x86_64 2:8.17.0-1nodesource

Complete!
[root@centos-linux-e]# node -v
v8.17.0
[root@centos-linux-e]# npm -v
6.13.4

你可能感兴趣的:(CentOS 中安装 Nodejs)