CentOS使用yum方式安装yarn和nodejs

# 使用epel-release.repo源安装的nodejs版本是6.17.1,有些前端项目使用的话会提示版本太低,具体下图
# 命令执行后的详细情况:curl -sL https://rpm.nodesource.com/setup_8.x | 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://rpm.nodesource.com/setup_10.x - Node.js v10 LTS "Dubnium"
   * https://rpm.nodesource.com/setup_12.x - Node.js v12 LTS "Erbium"
   * https://rpm.nodesource.com/setup_14.x - Node.js v14 LTS "Fermium" (recommended)
   * https://rpm.nodesource.com/setup_15.x - Node.js v15 "Fifteen"
   * https://rpm.nodesource.com/setup_16.x - Node.js v16 "Gallium"

  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.J9B5Zdf1Ud' '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.J9B5Zdf1Ud'

## Cleaning up...

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

## Checking for existing installations...

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

## Your system appears to already have Node.js installed from an alternative source.
Run `sudo yum remove -y nodejs npm` to remove these first.


## 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
curl -sL https://rpm.nodesource.com/setup_8.x | bash -
yum install -y nodejs yarn 

原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/14721361.html