centOS无法通过yum安装nodejs

时间:2016-06-19 09:29:05

标签: node.js linux centos yum

我在我的centOS服务器上使用节点v0.10.x并且我想更新node.js,所以接下来是一些文章。首先删除当前安装的:

# which node
# cd /usr
# rm -r bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node.1

然后检查节点-v不工作,好。但使用yum不会安装最新的Node.js,所以我搜索了一些帖子并发现了这个: https://www.metachris.com/2015/10/how-to-install-nodejs-5-on-centos-and-ubuntu/

所以我按照命令:

# rpm -Uvh https://rpm.nodesource.com/pub_5.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm
# yum install nodejs -y

这就是问题所在。它打印出许多错误并一直失败。

Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 0:0.10.42-4.el6 will be updated
--> Processing Dependency: nodejs(x86-64) = 0.10.42-4.el6 for package:     nodejs-devel-0.10.42-4.el6.x86_64
---> Package nodejs.x86_64 0:5.11.1-1nodesource.el7.centos will be an update
--> Running transaction check
---> Package nodejs-devel.x86_64 0:0.10.42-4.el6 will be updated
---> Package nodejs-devel.x86_64 0:5.11.1-1nodesource.el7.centos will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package         Arch      Version                          Repository     Size
================================================================================
Updating:
 nodejs          x86_64    5.11.1-1nodesource.el7.centos    nodesource    8.7 M
Updating for dependencies:
 nodejs-devel    x86_64    5.11.1-1nodesource.el7.centos    nodesource    7.6 M

Transaction Summary
================================================================================
Upgrade  1 Package (+1 Dependent package)

Total size: 16 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test


Transaction check error:
  file /usr/lib/node_modules/npm/node_modules/semver/package.json from install of nodejs-5.11.1-1nodesource.el7.centos.x86_64 conflicts with file from package nodejs-semver-2.1.0-1.el6.noarch
  file /usr/lib/node_modules/npm/node_modules/semver/bin/semver from     install of nodejs-5.11.1-1nodesource.el7.centos.x86_64 conflicts with file from package nodejs-semver-2.1.0-1.el6.noarch
  file /usr/lib/node_modules/npm/node_modules/semver/semver.js from install of nodejs-5.11.1-1nodesource.el7.centos.x86_64 conflicts with file from package nodejs-semver-2.1.0-1.el6.noarch
  ... and keeps going on ...

在删除节点之前,我也这样做了:

# npm cache clean -f
# npm install -g n
# n stable

但这根本不起作用,因为总是说版本0.10.x,甚至下载了最新版本! (我看过6.2.2或其他东西)

我认为在我的服务器上搞砸了一些东西,我不知道如何解决这个问题。任何人都可以提出一些建议吗?如果可以,我想安装最新的Node.js。

3 个答案:

答案 0 :(得分:3)

从EPEL存储库安装节点

foreach (Bar rod in bar)
{               
    if(rod.CollisionRectangle.Intersects(GameBall.CollisionRectangle))
    {
        GameBall.speed *= -1;
        Console.WriteLine("game" + GameBall.speed);                  
    }
}           

访问npm以管理其Node包。

yum update
yum install epel-release
yum install nodejs
node --version

答案 1 :(得分:1)

最简单的方法是使用nvm,即“ 节点版本管理器”。

在外壳中,执行以下操作:

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

注意如果您想在运行脚本之前先了解该脚本,请阅读nvm github page上的文档和/或删除 | bash 从curl命令读取而不运行.sh文件

关闭并重新打开外壳以使用更新的配置文件。然后:

//prints "nvm" if correctly installed
$ command -v nvm

// install latest version of node
$ nvm install node

//check it's installed correctly
$ node -v
v12.6.0

使用其他方法失败后,该方法没有问题。

答案 2 :(得分:0)

首先,您必须安装epe-release

sudo yum install epel-release

之后,您可以安装node.js和npm

sudo yum -y install nodejs npm

对我有用。