【问题标题】:Installing nodejs on Red Hat在红帽上安装 nodejs
【发布时间】:2015-01-05 11:28:44
【问题描述】:

我正在尝试使用以下命令在 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)

我应该如何安装它?我想安装最新版本。

【问题讨论】:

    标签: node.js redhat yum


    【解决方案1】:

    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

    【讨论】:

    • 嗨,我用这种方式,但是“没有可用的包 nodejs”。还是发生了?我能做什么?谢谢
    • 上面的脚本很快就会被弃用,取而代之的是版本特定的脚本: curl -sL rpm.nodesource.com/setup_4.x |重击-
    • @liamxu 我遇到了同样的问题。解决方案是我在 sudo 中忘记了 -E。如果您不以 root 身份运行,例如使用 https_proxy,则必须在管道后使用 sudo -E bash -。正如脚本介绍本身所写,但被我忽略了很长一段时间
    【解决方案2】:

    我没有代表对 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
    

    【讨论】:

      【解决方案3】:

      您需要将您的 CentOS 6 版本更新到 6.5+ 或至少您的 OpenSSL 副本,因为为 CentOS 6 提供的 node.js 包是 compiled on a system that had a newer version of OpenSSL,它在 6.5+ 中可用。

      另一种方法是从源代码手动编译和安装 node 或使用 nodejs.org 中的预编译二进制文件。

      【讨论】:

        【解决方案4】:

        正如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
        

        【讨论】:

        • sudo su root -curl --silent --location https://rpm.nodesource.com/setup_9.x | bash - 为我工作
        【解决方案5】:

        如果此命令不起作用,请访问...

        https://rpm.nodesource.com/setup

        在您的浏览器中

        它提供了有关如何使用 wget 的说明。

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

        也许这会对某人有所帮助!

        【讨论】:

          【解决方案6】:

          IMO 应将@Eric Soyke 的答案标记为正确答案。如果您需要 node 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
          

          【讨论】:

            【解决方案7】:

            它对我有用。以超级用户身份运行这两个命令。

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

            【讨论】:

              【解决方案8】:

              我建议使用dnf 安装您需要的NodeJS 版本,因为yum 可能会拉错版本。如所见Here

              列出可用的版本;

              sudo dnf module list nodejs
              

              安装你想要的:

              sudo dnf module install nodejs:14
              

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 2012-09-29
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 2015-06-07
                • 2014-04-14
                • 2015-05-26
                • 2017-08-20
                相关资源
                最近更新 更多