18

Note: This is partially solved, but needs a little more attention. See notes at bottom of OP, and @Digisec's partial answer.

I am trying to set up Node.js on CentOS 7, but the following commands are failing to install the latest version. What do I have to change in the code below to install the newest version of Node.js on CentOS 7?

I start by typing node --version which results in v0.12.7. This is clearly an old version because nodejs.org says that v5.6.0 is the latest stable version.

So then I type the following to get the latest version of node.js:

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

The terminal prints out that I should type the following to remove the outdated version of node.js, so I type the following:

yum remove -y nodejs npm

The terminal also says to type the following to install the newest version of node.js, so I type the following:

yum install -y nodejs

But then I type node --version again, and the terminal replies with v0.12.7 again, showing that the preceding commands, simply re-installed the old outdated version again.

So what do I need to do in order to get the newest stable version of node.js installed on the CentOS 7 machine?


ONGOING EFFORTS:


As per @Digisec's suggestion, I re-ran the above commands, but this time recorded all the output into the following text. Please note that the sequence is slightly different now that I am running it again, but the result is the same, as follows:

[root@localhost ~]# node --version
v0.12.7
[root@localhost ~]# cd /tmp
[root@localhost tmp]# curl -sL https://rpm.nodesource.com/setup | bash -

## Installing the NodeSource Node.js 0.10 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_0.10/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.ePYEdVWXQH' 'https://rpm.nodesource.com/pub_0.10/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.ePYEdVWXQH'

## Cleaning up...

+ rm -f '/tmp/tmp.ePYEdVWXQH'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `yum install -y nodejs` (as root) to install Node.js 0.10 and npm.
## You may also need development tools to build native addons:
##   `yum install -y gcc-c++ make`

[root@localhost tmp]# yum remove -y nodejs npm
Loaded plugins: fastestmirror, langpacks
No Match for argument: npm
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 0:0.10.42-1nodesource.el7.centos will be erased
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================================
 Package                             Arch                                Version                                                     Repository                                Size
====================================================================================================================================================================================
Removing:
 nodejs                              x86_64                              0.10.42-1nodesource.el7.centos                              @nodesource                               16 M

Transaction Summary
====================================================================================================================================================================================
Remove  1 Package

Installed size: 16 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : nodejs-0.10.42-1nodesource.el7.centos.x86_64                                                                                                                         1/1 
  Verifying  : nodejs-0.10.42-1nodesource.el7.centos.x86_64                                                                                                                         1/1 

Removed:
  nodejs.x86_64 0:0.10.42-1nodesource.el7.centos                                                                                                                                    

Complete!
[root@localhost tmp]# yum install -y nodejs
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: www.gtlib.gatech.edu
 * epel: mirror.sfo12.us.leaseweb.net
 * extras: dallas.tx.mirror.xygenhosting.com
 * updates: linux.mirrors.es.net
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:
nodejs-0.10.42-1nodesource.el7.centos.x86_64.rpm                                                                                                             | 4.5 MB  00:00:09     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : nodejs-0.10.42-1nodesource.el7.centos.x86_64                                                                                                                         1/1 
  Verifying  : nodejs-0.10.42-1nodesource.el7.centos.x86_64                                                                                                                         1/1 

Installed:
  nodejs.x86_64 0:0.10.42-1nodesource.el7.centos                                                                                                                                    

Complete!
[root@localhost tmp]# node --version
v0.12.7
[root@localhost tmp]#   

Then, as per @Digisec's answer, I next tried the following, but the result is still failing to install the proper version, as you can see from the following terminal output:

[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.NEM1bxM9WB' '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.NEM1bxM9WB'

## Cleaning up...

+ rm -f '/tmp/tmp.NEM1bxM9WB'

## 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`

[root@localhost tmp]# yum remove -y nodejs npm
Loaded plugins: fastestmirror, langpacks
No Match for argument: npm
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 0:0.10.42-1nodesource.el7.centos will be erased
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================================
 Package                             Arch                                Version                                                     Repository                                Size
====================================================================================================================================================================================
Removing:
 nodejs                              x86_64                              0.10.42-1nodesource.el7.centos                              @nodesource                               16 M

Transaction Summary
====================================================================================================================================================================================
Remove  1 Package

Installed size: 16 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : nodejs-0.10.42-1nodesource.el7.centos.x86_64                                                                                                                             1/1 
  Verifying  : nodejs-0.10.42-1nodesource.el7.centos.x86_64                                                                                                                             1/1 

Removed:
  nodejs.x86_64 0:0.10.42-1nodesource.el7.centos                                                                                                                                    

Complete!
[root@localhost tmp]# yum install -y nodejs
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: www.gtlib.gatech.edu
 * epel: mirror.sfo12.us.leaseweb.net
 * extras: dallas.tx.mirror.xygenhosting.com
 * updates: linux.mirrors.es.net
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:
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]# yum install -y nodejs
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: www.gtlib.gatech.edu
 * epel: mirror.sfo12.us.leaseweb.net
 * extras: dallas.tx.mirror.xygenhosting.com
 * updates: linux.mirrors.es.net
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]# node --version
v0.12.7
[root@localhost tmp]# 

I then visited the knowledge base article referenced by the error log above, but found that I cannot access the full article because I am not a Red Had customer.


PARTIAL SOLUTION:


@Digisec partially solved this by showing how to install the new version, but we are still not able to remove the old version, which will leave the risk of conflicts going forward. What steps need to be taken to remove the old version so that the new install can be clean and complete?

I found the tar url for the old version v0.12.7 at this link. And @Digisec' also suggested reading this other link, which suggests using the command make uninstall. I get the sense that there might only be five or ten commands to type in the terminal to remove the old v0.12.7 and re-install the new version of nodejs. What are the required commands?

I seem to have found three tar files on the CentOS 7 machine that are related to nodejs v0.12.7 using the following terminal commands:

[root@localhost ~]# cd /
[root@localhost /]# find . -type f -iname "*.tar"
find: ‘./run/user/1000/gvfs’: Permission denied
./opt/node-v0.12.7/deps/npm/node_modules/tar/test/dir-normalization.tar
./opt/node-v0.12.7/deps/npm/test/fixtures/gitignore-and-npmignore-2.tar
./opt/node-v0.12.7/deps/npm/test/fixtures/gitignore-and-npmignore.tar
./usr/local/lib/node_modules/npm/test/fixtures/gitignore-and-npmignore-2.tar
./usr/local/lib/node_modules/npm/test/fixtures/gitignore-and-npmignore.tar
./usr/local/lib/node_modules/npm/node_modules/tar/test/dir-normalization.tar
[root@localhost /]# 

Note that there are an additional three tar files marked node_modules whose relationship with v0.12.7 is not clear.

What specific commands do I run to safely uninstall v0.12.7 and remove all the v0.12.7 associated tar files from the machine?

3
  • It would be a good idea to post all output as well. That would help to see what's happening to be able to better help you. Commented Feb 13, 2016 at 3:41
  • @Digisec I re-ran the commands and then added the complete output to the OP, as you requested. Can I do anything else to help isolate the problem? Commented Feb 13, 2016 at 3:53
  • FWIW you may now uninstall NodeJS' old version with yum remove -y nodejs. Commented Jul 29, 2019 at 6:04

8 Answers 8

10

I just checked the link you got this from. You are installing, specifically, version 0.10, or trying to at least, but you have a newer version in the repo that's being installed. You have to follow the setup for node v5.

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

PS: for future reference, make sure you read the sites very carefully especially when running commands as root.

EDIT: Alright, it seems that you added the repo correctly. Looking into the repo, your packages are there but the system is looking for the wrong version. At this point, I would suggest.

yum clean all && yum update

That will clean cached repo and grab from remote.

Answer: After the work we've done over the chat, here's the correct answer for you. nodejs v5 installed fine. You previously compiled nodejs v0.12 manually, which is not a good idea on binary distros, because you will end up in this position.

which node

returned

/usr/local/bin/node

while

/usr/bin/node

returned the correct answer of v5.x.

At this point you have multiple options to fix it, but I would recommend 2.

  • Option 1: This is the easy way out. You can edit your .bashrc and add an alias that will point node -> /usr/bin/node. This is as simple as adding alias node="/usr/bin/node". This will call the correct version every time but I cannot guarantee that it will not cause conflicts in the future with libraries.
  • Option 2: This is the hard way, but it will fix it. First, purge with yum the nodejs that is installed on the system. Second, get the tarball for the version you have compiled, untar it, ./configure and uninstall it. This step, you can find online easily. Finally, reinstall nodejs through yum, and that should fix your problem.
11
  • Thank you for looking into this, but this is still not fully fixing the problem. Please see the additional terminal output that I added to the end of the OP documenting the results of trying your suggestion. What else can I try? Commented Feb 13, 2016 at 4:34
  • @CodeMed I updated the answer and it would be a better idea to get onto the chat. Commented Feb 13, 2016 at 4:52
  • That did not resolve the problem. If you are still willing to chat, I created the following room: chat.stackexchange.com/rooms/35670/… Commented Feb 13, 2016 at 5:12
  • @CodeMed good luck with fixing your issue. Commented Feb 13, 2016 at 5:34
  • Are you willing to elaborate on your option 2? Or should I post a separate question? Commented Feb 13, 2016 at 6:49
5

What I did:

rm -f /etc/yum.repos.d/nodesource-el*
curl -sL https://rpm.nodesource.com/setup_7.x | bash -
yum install -y nodejs
node --version

and I got:

v7.2.0
1
  • Thank you! This was the only solution that helped me. Commented Feb 28, 2019 at 23:13
3

CentOS 7.2, NodeJS 6.7.0 (https://nodejs.org/download/release/v6.7.0/ ). Manually install

wget https://nodejs.org/download/release/v6.7.0/node-v6.7.0.tar.gz
./configure
make
make install

to uninstall make uninstall

1

I tried install node from same NodeSource RepoInstaller. For my way problem solved by enabled nodesource repo. Change enabled=0 to enabled=1 and all should works.

[root@web ~]# cat /etc/yum.repos.d/nodesource-el.repo
[nodesource]
name=Node.js Packages for Enterprise Linux 7 - $basearch
baseurl=https://rpm.nodesource.com/pub_6.x/el/7/$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
1

Same issue here. What i dod to solve it was:

ALL MUST BE EXECUTED AS ROOT or at least add SUDO at the beginning of each command

Uninstall nodejs - in my case node v8

yum uninstall nodejs npm

remove actual repository from /etc/yum.repos.d

rm /etc/yum.repos.d/nodesource*

Update your repository

yum update

Get te updated repository - in my case node v14

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

I like to do a new yum update (it's optional)

yum update

Install the new version of node

yum install nodejs

Enjoy

no code available for this
0

I was also having some problems getting the new versions of npm and nodejs installed on CentOS 7.

I followed the instructions on the nodejs site then tried to install npm. This turned out to be the problem (npm was installing from EPEL). The Nodesource repository does not provide individual packages for npm as is the case for EPEL. Instead everything is inside a single package 'nodejs'. So once you install nodejs from Nodesource you now have automatically installed npm and are ready to go on the updated version.

0

I was struggling with the same problem, nor yum clean all nor rm -f /etc/yum.repos.d/nodesource* helped. Then I found that yum used the Epel repository to install node so I disabled it temporarily (in /etc/yum.repos.d/epel.repo set enabled=0) and after that

curl -sL https://rpm.nodesource.com/setup_8.x | bash -
yum install nodejs
0

I have also faced the same issue.

Solution: 1. Go to /tmp location remove all files and folders.

cd /tmp
rm -rf *

2. now you can use the commands below to install NodeJs

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.