簡體   English   中英

在 Red Hat 上安裝 nodejs

[英]Installing nodejs on Red Hat

我正在嘗試使用以下命令在 Red Hat Enterprise Linux Server 6.1 版上安裝 node.js:

sudo yum install nodejs npm

我收到以下錯誤:

Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
           Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
           Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
           Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Error: Package: nodejs-devel-0.10.24-1.el6.x86_64 (epel)
           Requires: libssl.so.10(libssl.so.10)(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

我也嘗試了以下命令:

sudo yum install -y nodejs

我收到以下錯誤:

Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
           Requires: libssl.so.10(libssl.so.10)(64bit)
Error: Package: nodejs-0.10.24-1.el6.x86_64 (epel)
           Requires: libcrypto.so.10(libcrypto.so.10)(64bit)

我應該如何安裝它? 我想安裝最新版本。

NodeJS 提供了一個安裝腳本,在使用 yum 安裝之前必須運行該腳本

curl -sL https://rpm.nodesource.com/setup | bash -

然后 yum 命令應該可以工作

yum install -y nodejs

https://github.com/joyent/node/wiki/installing-node.js-via-package-manager#enterprise-linux-and-fedora

我沒有代表對 jfredys 的回答發表評論,但想添加一個附錄。 他的回答對於我假設的某些環境是正確的,但是當我遇到錯誤時它失敗了:

您的發行版,標識為“redhat-release-server-6Server-6.6.0.2.el6.x86_64”,目前不受支持,如果您認為這是不支持的,請通過https://github.com/nodesource/distributions/issues聯系 NodeSource不正確或希望考慮支持您的發行版

我最近在嘗試在另一台服務器上安裝流星包時遇到了奇怪的問題,結果是 curl 嘗試訪問 SSL 站點的代理/防火牆問題。 我不得不更改所有 curl 命令以使用 -k 來繞過錯誤的 SSL 警告。 首先我在本地復制了安裝腳本:

curl -kL https://rpm.nodesource.com/setup > ~/nodeInstall.sh

當我在那里時,我刪除了 s(靜默)選項以深入了解任何問題(幸運的是沒有)。 在腳本中,我將所有 curl 命令更改為使用 -k(為了以防萬一,還刪除了靜默選項)。 我將它設置為可執行文件並且它運行得很干凈(在 sudo 下),然后我終於能夠安裝 npm

sudo yum install -y nodejs

一切都很開心:

$npm -version
1.4.28

您需要將 CentOS 6 的版本更新到 6.5+ 或至少是 OpenSSL 的副本,因為為 CentOS 6 提供的 node.js 包是在具有較新版本 OpenSSL 的系統上編譯的,該版本可在 6.5+ 中使用。

另一種方法是從源代碼手動編譯和安裝節點,或者使用來自 nodejs.org 的預編譯二進制文件。

就像每個https://nodejs.org/en/download/package-manager/你必須啟動:

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

或者

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

取決於您需要的 NodeJS 版本。 然后簡單地運行

yum -y install nodejs

如果此命令不起作用,請訪問...

https://rpm.nodesource.com/setup

在您的瀏覽器中

它給出了如何使用 wget 的說明。

wget -qO- https://rpm.nodesource.com/setup | bash -

也許這會幫助某人!

IMO @Eric Soyke 的答案應該被標記為正確的答案。 如果您想要節點 v4,需要更改的一件事是將“setup”替換為“setup_4.x”。

命令序列(至少對於 root 用戶)是這樣的:

curl -kL https://rpm.nodesource.com/setup > ~/nodeInstall.sh
# or for v4 / v6:
#  curl -kL https://rpm.nodesource.com/setup_4.x > ~/nodeInstall.sh
#  curl -kL https://rpm.nodesource.com/setup_6.x > ~/nodeInstall.sh
sed -i -e 's_curl _curl -k _g' nodeInstall.sh
chmod u+x nodeInstall.sh
./nodeInstall.sh
yum -y install nodejs
rm nodeInstall.sh

它對我有用。 以超級用戶身份運行這兩個命令。

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

sudo yum install -y nodejs

我建議使用dnf來安裝您需要的 NodeJS 版本,因為yum可能會拉錯版本。 這里所見

列出可用版本;

sudo dnf module list nodejs

安裝你想要的:

sudo dnf module install nodejs:14

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM