在 Red Hat 上安装 nodejs
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27778593/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing nodejs on Red Hat
提问by Prachi g
I am trying to install node.js on Red Hat Enterprise Linux Server release 6.1 using the following command:
我正在尝试使用以下命令在 Red Hat Enterprise Linux Server 6.1 版上安装 node.js:
sudo yum install nodejs npm
I got the following error:
我收到以下错误:
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
I tried the following command as well:
我也尝试了以下命令:
sudo yum install -y nodejs
I am getting the following error:
我收到以下错误:
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)
How should I install it? I want to install the latest version.
我应该如何安装它?我想安装最新版本。
采纳答案by mscdex
You need to update your version of CentOS 6 to 6.5+ or at least your copy of OpenSSL because the node.js package provided for CentOS 6 was compiled on a system that had a newer version of OpenSSLwhich is available in 6.5+.
您需要将您的 CentOS 6 版本更新到 6.5+ 或至少您的 OpenSSL 副本,因为为 CentOS 6 提供的 node.js 包是在具有较新版本 OpenSSL 的系统上编译的,该版本可在 6.5+ 中使用。
The alternative is to compile and install node manually from source or use the precompiled binaries from nodejs.org.
另一种方法是从源代码手动编译和安装节点,或者使用来自 nodejs.org 的预编译二进制文件。
回答by jfredys
NodeJS provides a setup script that must run before you install it with yum
NodeJS 提供了一个安装脚本,在使用 yum 安装之前必须运行该脚本
curl -sL https://rpm.nodesource.com/setup | bash -
Then the yum command should work
然后 yum 命令应该可以工作
yum install -y nodejs
回答by Eric Soyke
I don't have the rep to comment on jfredys' answer, but wanted to add an addendum. His answer is correct for certain environments I assume, but it failed for me as I was running into the error:
我没有代表对 jfredys 的回答发表评论,但想添加一个附录。他的回答对于我假设的某些环境是正确的,但是当我遇到错误时它失败了:
Your distribution, identified as "redhat-release-server-6Server-6.6.0.2.el6.x86_64", is not currently supported, please contact NodeSource at https://github.com/nodesource/distributions/issuesif you think this is incorrect or would like your distribution to be considered for support
您的发行版,标识为“redhat-release-server-6Server-6.6.0.2.el6.x86_64”,目前不受支持,如果您认为这是不支持的,请通过https://github.com/nodesource/distributions/issues联系 NodeSource不正确或希望考虑支持您的发行版
I had run into weirdness trying to install meteor packages on another server recently and it turned out to be a proxy/firewall issue with curl trying to hit SSL sites. I had to alter all curl commands to use -k to bypass false SSL warnings. First I copied the install script locally:
我最近在尝试在另一台服务器上安装流星包时遇到了奇怪的问题,结果是 curl 试图访问 SSL 站点的代理/防火墙问题。我不得不更改所有 curl 命令以使用 -k 来绕过错误的 SSL 警告。首先我在本地复制了安装脚本:
curl -kL https://rpm.nodesource.com/setup > ~/nodeInstall.sh
While I was at it I removed the s (silent) option to give some insight into any problems (fortunately there were none). In the script I changed all the curl commands to use -k (also removed the silent option just in case). I set it executable and this ran cleanly (under sudo), I was then finally able to install npm with
当我在那里时,我删除了 s(静默)选项以深入了解任何问题(幸运的是没有)。在脚本中,我将所有 curl 命令更改为使用 -k(为了以防万一,还删除了静默选项)。我将它设置为可执行文件并且它运行得很干净(在 sudo 下),然后我终于能够安装 npm
sudo yum install -y nodejs
And all was happy:
一切都很开心:
$npm -version
1.4.28
回答by Tomas P. R.
Just as per https://nodejs.org/en/download/package-manager/you have to launch:
就像每个https://nodejs.org/en/download/package-manager/你必须启动:
curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
or
或者
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
depending on NodeJS version you need. Then simply run
取决于您需要的 NodeJS 版本。然后简单地运行
yum -y install nodejs
回答by danday74
if this command is not working then visit ...
如果此命令不起作用,请访问...
https://rpm.nodesource.com/setup
https://rpm.nodesource.com/setup
in your browser
在您的浏览器中
It gives instructions on how to use wget instead.
它给出了如何使用 wget 的说明。
wget -qO- https://rpm.nodesource.com/setup | bash -
maybe that will help someone!
也许这会帮助某人!
回答by ishahak
IMO the answer by @Eric Soyke should be marked as the correct one. One thing to change in case you want node v4, is to replace 'setup' with 'setup_4.x'.
IMO @Eric Soyke 的答案应该被标记为正确的答案。如果您想要节点 v4,需要更改的一件事是将“setup”替换为“setup_4.x”。
The sequence of commands (at least for a root user) is this:
命令序列(至少对于 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
回答by Pablo Navarro
It worked for me. Run both commands as super user.
它对我有用。以超级用户身份运行这两个命令。
sudo curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
sudo yum install -y nodejs

