CentOS – Why Yum is Installing the Wrong Version of Node.js

centosnode.jsterminalyum

On a CentOS 7 server, I am trying to install version 5.x of Node.js, but for some reason, yum keeps trying to install version 0.x and returning an error when it cannot find version 0.x at the 5.x download site. The error indicates that yum is concatenating a version 0.x file name with a version 5.x url. I assume this points to something wrong in the config for yum on the CentOS 7 machine. What specific changes to the below need to be made to install version 5.x?

The root error message is:

Error downloading packages:
  nodejs-0.10.42-1nodesource.el7.centos.x86_64: [Errno 256] No more mirrors to try.

The publisher page from which my code below originated can be viewed at the following link. Also, some complication may be resulting from an earlier attempt following instructions at this other link. And to explore the possible remnants of the earlier attempt, I am currently running the following command and waiting for the results: grep -rnw '/path/to/somewhere/' -e "pattern"

Here is the terminal output for setting the nodesource location:

[root@localhost tmp]# curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
## Installing the NodeSource Node.js 5.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_5.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Downloading release setup RPM...
+ mktemp
+ curl -sL -o '/tmp/tmp.sH82u4Gpap' 'https://rpm.nodesource.com/pub_5.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Installing release setup RPM...
+ rpm -i --nosignature --force '/tmp/tmp.sH82u4Gpap'
## Cleaning up...
+ rm -f '/tmp/tmp.sH82u4Gpap'
## Checking for existing installations...
+ rpm -qa 'node|npm' | grep -v nodesource
## Run `yum install -y nodejs` (as root) to install Node.js 5.x and npm.
## You may also need development tools to build native addons:
##   `yum install -y gcc-c++ make`

Here is a listing of the contents of the /tmp folder after the above command:

[root@localhost tmp]# ls -al
total 8
drwxrwxrwt. 13 root   root    320 Feb 14 06:13 .
dr-xr-xr-x. 19 root   root   4096 Jan 29 20:54 ..
drwx------.  2 user   user     60 Feb 13 20:05 .esd-1000
drwxrwxrwt.  2 root   root     40 Feb 13 20:04 .font-unix
prw-------.  1 root   root      0 Feb 13 20:05 hogsuspend
drwxrwxrwt.  2 root   root     80 Feb 13 20:05 .ICE-unix
srwxrwxrwx.  1 mongod mongod    0 Feb 13 20:04 mongodb-27017.sock
drwx------.  2 user   user     40 Dec 31  1969 orbit-user
drwx------.  2 user   user     60 Feb 13 20:05 ssh-AmQyH8IIEC2m
drwx------.  3 root   root     60 Feb 13 20:05 systemd-private-74534ca9946043cc88dbe52a38b4344d-colord.service-hDR3Cd
drwx------.  3 root   root     60 Feb 13 20:04 systemd-private-74534ca9946043cc88dbe52a38b4344d-rtkit-daemon.service-ZAQmPk
drwxrwxrwt.  2 root   root     40 Feb 13 20:04 .Test-unix
drwx------.  2 user   user     40 Feb 13 20:08 tracker-extract-files.1000
-r--r--r--.  1 root   root     11 Feb 13 20:05 .X0-lock
drwxrwxrwt.  2 root   root     60 Feb 13 20:05 .X11-unix
drwxrwxrwt.  2 root   root     40 Feb 13 20:04 .XIM-unix

Here are the results of trying to install nodejs using yum:

[root@localhost tmp]# yum install -y nodejs
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.lax.hugeserver.com
 * epel: mirror.sfo12.us.leaseweb.net
 * extras: mirror.keystealth.org
 * updates: mirror.supremebytes.com
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 0:0.10.42-1nodesource.el7.centos will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================================================================
 Package                            Arch                               Version                                                     Repository                              Size
================================================================================================================================================================================
Installing:
 nodejs                             x86_64                             0.10.42-1nodesource.el7.centos                              nodesource                             4.5 M

Transaction Summary
================================================================================================================================================================================
Install  1 Package

Total download size: 4.5 M
Installed size: 16 M
Downloading packages:
No Presto metadata available for nodesource
nodejs-0.10.42-1nodesource.el7 FAILED                                          
https://rpm.nodesource.com/pub_5.x/el/7/x86_64/nodejs-0.10.42-1nodesource.el7.centos.x86_64.rpm: [Errno 14] HTTPS Error 404 - Not Found       ]  0.0 B/s |    0 B  --:--:-- ETA 
Trying other mirror.
To address this issue please refer to the below knowledge base article 

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/

Error downloading packages:
  nodejs-0.10.42-1nodesource.el7.centos.x86_64: [Errno 256] No more mirrors to try.
[root@localhost tmp]# 

For the record, gedit /etc/yum.repos.d/nodesource-el.repo shows the following:

[nodesource]
name=Node.js Packages for Enterprise Linux 7 - $basearch
baseurl=https://rpm.nodesource.com/pub_5.x/el/7/$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL

[nodesource-source]
name=Node.js for Enterprise Linux 7 - $basearch - Source
baseurl=https://rpm.nodesource.com/pub_5.x/el/7/SRPMS
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
gpgcheck=1  

I suspect that the problem might be resultimg from having run this other command previously:

curl --silent --location rpm.nodesource.com/setup | bash -

I am guessing that the underlying problem is how yum persists the results of those curl --silent --location ... | bash - commands


CONTROL CASE:


On a different, completely fresh installation of CentOS 7 on a different Virtual Machine, the following three simple commands successfully installed the correct current version 5.x of nodejs:

# cd /tmp
# curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
# yum install -y nodejs  
# node --version
v5.6.0  

These results from the control case indicate that the problem is in how yum is configured in the machine that is having the problem. So what specific changes need to be made to the machine with the problem so that yum is configured to generate the correct download url? It is not reasonable to port everything to a different VM. Surely this is just a line or two in a yum config somewhere that can be changed to resolve this problem.

Best Answer

This appears to have been a cache issue, though it's unclear what went wrong. After some conversation with the poster in chat, running yum clean all fixed the issue.

The poster noted the following:

[root@localhost yum]# ls /var/cache/yum/x86_64/7/nodesource/packages 
nodejs-0.10.42-1nodesource.el7.centos.x86_64.rpm 
[root@localhost yum]# yum clean all
[root@localhost yum]# ls /var/cache/yum/x86_64/7/nodesource/packages 
[root@localhost yum]# yum install -y nodejs
.... much terminal output during successful install
[root@localhost yum]# node --version
v5.6.0

So the yum clean all deleted the obsolete package that had been stored in the cache.

I don't have sufficient knowledge or experience of Red Hat based distributions to say what went wrong here, so will refrain from commenting further.

Related Question