Redhat

RHEL7——安裝 NodeJS 10?

  • July 11, 2020

我已按照以下連結中顯示的說明進行操作,但無法在 RHEL7 上安裝 NodeJS v10。

curl -sL https://rpm.nodesource.com/setup_10.x | sudo -E bash -
yum install nodejs

我收到以下消息:

## Installing the NodeSource Node.js 10.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_10.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Downloading release setup RPM...

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

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.p7C7NIfygt'
warning: /etc/yum.repos.d/nodesource-el7.repo created as /etc/yum.repos.d/nodesource-el7.repo.rpmnew

## Cleaning up...

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

## Checking for existing installations...

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

## Run `sudo yum install -y nodejs` to install Node.js 10.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

Package matching 1:nodejs-6.16.0-1.el7.x86_64 already installed. Checking for update.
Nothing to do

yum --showduplicates list nodejs |expand顯示:

Installed Packages
nodejs.x86_64                  2:9.6.0-1nodesource                   @nodesource
Available Packages
nodejs.x86_64                  1:6.12.2-1.el7                        localepel  
nodejs.x86_64                  1:6.12.3-1.el7                        localepel  
nodejs.x86_64                  1:6.14.0-1.el7                        localepel  
nodejs.x86_64                  1:6.14.2-1.el7                        localepel  
nodejs.x86_64                  1:6.14.3-1.el7                        localepel  
nodejs.x86_64                  1:6.16.0-1.el7                        localepel 

node -v顯示:

v9.6.0

無論我做什麼,我似乎都無法安裝 v10。

資料來源:

我看到的問題是該系統以前從 nodesource 安裝了 nodejs 9.x,並且在嘗試安裝 nodejs 10 之前,nodesource 設置腳本和系統管理員都沒有刪除它及其儲存庫。

更糟糕的是,腳本實際上忽略了這個問題,並試圖繼續前進,儘管它不可能工作。(這個問題應該報告給它的維護者。)

要解決此問題,請先刪除提供 nodejs 9.x 的 yum repo,然後再次執行 nodejs 10.x 的安裝腳本。

yum remove $(rpm -qf /etc/yum.repos.d/nodesource.repo)

這應該足以清理系統,以便嘗試安裝 nodejs 10.x 將成功。

引用自:https://serverfault.com/questions/957126