将Node.js安装在VPS上

[root@<ホスト名> ~]# curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
## Installing the NodeSource Node.js 14.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_14.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Downloading release setup RPM...

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

## Installing release setup RPM...

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

## Cleaning up...

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

## Checking for existing installations...

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

## Run `sudo yum install -y nodejs` to install Node.js 14.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@<ホスト名> ~]# yum install nodejs
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.riken.jp
 * extras: ftp.iij.ad.jp
 * updates: ty1.mirror.newmediaexpress.com
nodesource                                                                             | 2.5 kB  00:00:00     
nodesource/x86_64/primary_db                                                           |  42 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 2:14.17.1-1nodesource will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
 Package              Arch                 Version                             Repository                Size
==============================================================================================================
Installing:
 nodejs               x86_64               2:14.17.1-1nodesource               nodesource                32 M

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

Total download size: 32 M
Installed size: 92 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/nodesource/packages/nodejs-14.17.1-1nodesource.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 34fa74dd: NOKEY
Public key for nodejs-14.17.1-1nodesource.x86_64.rpm is not installed
nodejs-14.17.1-1nodesource.x86_64.rpm                                                  |  32 MB  00:00:03     
Retrieving key from file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Importing GPG key 0x34FA74DD:
 Userid     : "NodeSource <gpg-rpm@nodesource.com>"
 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
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : 2:nodejs-14.17.1-1nodesource.x86_64                                                        1/1 
  Verifying  : 2:nodejs-14.17.1-1nodesource.x86_64                                                        1/1 

Installed:
  nodejs.x86_64 2:14.17.1-1nodesource                                                                         

Complete!
[root@<ホスト名> ~]# node -v
v14.17.1
[root@<ホスト名> ~]# npm -v
6.14.13
广告
将在 10 秒后关闭
bannerAds