Why won't the correct new version of Node.js install on CentOS 7?
Solution 1
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 analias
that will pointnode -> /usr/bin/node
. This is as simple as addingalias 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, reinstallnodejs
throughyum
, and that should fix your problem.
Solution 2
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
Solution 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
Solution 4
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
Solution 5
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
Related videos on Youtube
RabT
Updated on September 18, 2022Comments
-
RabT over 1 year
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 inv0.12.7
. This is clearly an old version becausenodejs.org
says thatv5.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 withv0.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 withv0.12.7
is not clear.What specific commands do I run to safely uninstall
v0.12.7
and remove all thev0.12.7
associated tar files from the machine?-
RabT over 8 years@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?
-
avazula almost 5 yearsFWIW you may now uninstall NodeJS' old version with
yum remove -y nodejs
.
-
-
RabT over 8 yearsThank 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?
-
Digisec over 8 years@CodeMed I updated the answer and it would be a better idea to get onto the chat.
-
RabT over 8 yearsThat did not resolve the problem. If you are still willing to chat, I created the following room: chat.stackexchange.com/rooms/35670/…
-
Digisec over 8 years@CodeMed good luck with fixing your issue.
-
RabT over 8 yearsAre you willing to elaborate on your option 2? Or should I post a separate question?
-
Digisec over 8 years@CodeMed options 2 requires a basic knowledge in Linux so it might take time and might be harder, I added a link to help you through it. That is a question asked here.
-
RabT over 8 yearsYour link says to type
make uninstall
as root, but is not more specific than that. I have been using Linux for a few years, including administering a server for over a year and a devbox entirely in Linux for the same time. I think this is just perhaps 5 or 10 commands typed in the terminal, perhaps less. I added a link to the bottom of the OP. Are you willing to help me find the remaining few commands? -
Digisec over 8 years@CodeMed I have you what you need to to in here. Git the tar, untar, config, etc.
-
RabT over 8 yearsI located all the related tar files that are already on the machine, and I posted the list of their locations at the end of the OP. I do not know what specific commands to type to accomplish what you suggest, but perhaps listing these specific files will help you or someone else show what to type to resolve the rest of this problem. If you do not have the time to help further, I can post a separate question tomorrow. Thank you and +1 for your help so far.
-
Digisec over 8 years@CodeMed those are the installed ones. E said get the tarball and follow my steps.
-
RabT over 8 yearsAgain, I do not know how to do the steps that you are suggesting, so your comment is nearly worthless. I just posted a separate question because you clearly do not want to help any more. Have a nice day.
-
626 about 5 yearsThank you! This was the only solution that helped me.