For Ubuntu 12.04:

sudo apt-get remove nodejs

This will uninstall nodejs as well as npm.

Answer from Manoj Gupta on Stack Overflow
Top answer
1 of 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.
2 of 8
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
🌐
Techy Things
tech.yipp.ca › linux › uninstall-node-js-centos-6-7
Uninstall node.js on CentOS 6 7 - Techy Things
$> tar -xzvf node-0.10.46.tar.gz ... of just saying "". This was messing up some build scripts; so a reboot is needed.To just uninstall npm · $> sudo npm uninstall npm -g · Shareooo · 0 · 22 May, 2015 · 0 · 10 Apr, 2019 · 0 · 7 May, 2015 · Follow: Next story yum timeout ...
🌐
Stack Exchange
unix.stackexchange.com › questions › 592985 › how-do-i-remove-unnecessary-versions-of-node-in-centos
package management - How do I remove unnecessary versions of node in Centos - Unix & Linux Stack Exchange
It appears then that the /usr/local/bin/node version was installed via another means than the yum package manager (possibly via npm install node?), and in this case, you have to set the environment to use the non-yum installed version (you should probably see that your user account has /usr/local/bin in the PATH variable if you do echo $PATH).
Top answer
1 of 1
2

It's impossible to give you specific commands to perform the uninstallation because you don't give us the specific commands that were used to perform the installation. However, based on the information you give, this isn't a difficult task. I recommend that you stop your ongoing efforts — you seem to be doing some very complicated and useless things.

The manually-installed version has the binary in /usr/local/bin. That's good: it means that whoever installed it didn't make a complete mess. Just as a reminder: /bin, /lib, /bin and /usr outside /usr/local belong to the package manager; /usr/local belongs to the system administrator. You have manually-installed software under /usr/local; that's fine.

The binary package of node.js puts files under a common tree, containing:

  • Some documentation files in the toplevel directory.
  • bin/node and bin/npm
  • share/man/man1/node.1
  • lib/node_modules
  • share/systemtap/tapset/node.stp
  • include/node

Since node is in /usr/local/bin, look for the other files and directories under /usr/local as well, e.g. /usr/local/share/man/man1/node.1, etc. If you find them, remove them. If you don't find them, they may have been installed elsewhere, or not at all; you may try locate to find where they are (if they're present: the header files under include and the systemtap file aren't useful to everyone).

It looks like /opt/node-v0.12.7 is the source tree. You can remove that.

If you're worried about removing a file that turns out to be necessary, make sure your backups are up-to-date — or just move the files out of the way or keep a tarball of them while you test that your system still works.

If you're really worried and in a hurry, chances are that the manually-installed version doesn't conflict with the rpm version — there's only that node binary (and probably npm as well) that's ahead of the version in /usr/bin in the PATH. Rename /usr/local/bin/node to /usr/local/bin/node-0.12.7 (and likewise for npm) and node or #!/usr/bin/env node will invoke the system-installed version.

🌐
Usessionbuddy
usessionbuddy.com › post › How-To-Install-and-Upgrade-Nodejs-On-Linux
How To Install and Upgrade Nodejs On Linux
As of writing this post. Node.js v13.x is available. Lets first uninstall the existing nodejs version which is easy using yum remove command.
🌐
Stack Overflow
stackoverflow.com › questions › 50209052 › how-to-uninstall-node-js-on-centos-7
node.js - How to uninstall node js on centos 7 - Stack Overflow
I tried to all code command line ssh rm -r bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node.1 sudo apt-get remove nodejs sudo make uninstall ./configure then...
🌐
NgDeveloper
ngdeveloper.com › how-to-uninstall-node-js-from-cent-os
How to uninstall node js from cent os – NgDeveloper
January 18, 2022 - sudo yum remove nodejs · sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node opt/local/include/node /opt/local/lib/node_modules ·
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › node.js › uninstall-node-js-using-linux-command-line
Uninstall Node.JS Using Linux Command Line - GeeksforGeeks
October 17, 2024 - To determine the correct uninstallation method, you first need to know how Node.js was installed. The most common installation methods include: Package managers such as apt (for Ubuntu/Debian) or yum (for CentOS/RedHat).
🌐
Linuxteaching
en.linuxteaching.com › article › remove_node_js_centos_7
remove node js centos 7 | Linuxteaching
“how to uninstall nodejs from centos 7” Code Answer sudo rm -rf /usr/local/lib/node* sudo rm -rf /usr/local/include/node* sudo rm -rf /usr/local/bin/node* How do I uninstall node JS? How do I uninstall old Nodejs? How uninstall NPM Linux? How do I disable node js server in Linux?
🌐
Quora
quora.com › How-do-I-completely-uninstall-NodeJs-and-re-install-the-latest-version-of-NodeJs
How to completely uninstall NodeJs and re-install the latest version of NodeJs - Quora
Answer (1 of 8): EDIT 1 : On Linux : - Install the node version manager. [code]curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash [/code] * check if there is an installed node version : [code]node --version [/code] * if there exists a node version : [code]#...
🌐
GitHub
gist.github.com › teocci › 5ac7c3b59e255f414185b677717e620b
Installing Node.js in CentOS 7 · GitHub
sudo yum install -y gcc-c++ make curl curl -sL https://rpm.nodesource.com/setup_lts.x | bash - # Remove old version yum remove -y nodejs npm # Clear cache yum clean all # Install new Node.js yum install -y nodejs
🌐
Lavalite
lavalite.org › blog › uninstalling-nodejs-from-linux-using-cmd
Uninstalling Node.js from Linux using cmd - Lavalite
When you want to uninstall a program usually we uninstall from the UI. Lets see how to uninstall · Node.js from Linux using command prompt.
🌐
LinuxWays
linuxways.net › centos › how-to-install-node-js-on-centos-8
How to Install Node.js on CentOS 8 – LinuxWays
Use the following command, to remove or uninstall the NodeJS and npm modules from your CentOS 8 system: $ sudo yum module remove nodejs · Using the NVM (Node Version Manager) bash script, you can install and manage the NodeJS version on need.
🌐
LinuxVox
linuxvox.com › blog › uninstall-node-js-using-linux-command-line
How to Uninstall Node.js Using Linux Command Line: Step-by-Step Guide — linuxvox.com
Remove the Node.js package (retains configuration files): sudo apt remove nodejs · Purge configuration files (optional but recommended for a clean uninstall): sudo apt purge nodejs ·
🌐
GitHub
gist.github.com › dotcomputercraft › b7283bd52f4b5389e748
How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X) · GitHub
Clone this repository at <script src="https://gist.github.com/dotcomputercraft/b7283bd52f4b5389e748.js"></script> Save dotcomputercraft/b7283bd52f4b5389e748 to your computer and use it in GitHub Desktop. ... This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters ... I get a bunch of EPERM errors on sudo rm -rf ~/.node-gyp sudo rm /opt/local/bin/node..
🌐
Thrive My Way
thrivemyway.com › home › nodejs › how to uninstall node
How To Uninstall Node - Learn Digital Marketing
December 26, 2022 - The process for uninstalling Node.js on Linux will depend on how you originally installed it. If you installed Node.js using a package manager like apt or yum, you can use the following commands to uninstall it:
🌐
Programmersought
programmersought.com › article › 6161391642
Install and uninstall Node.js on Linux - Programmer Sought
Docker uninstallation and installation (CentOS 7) 1. Uninstall: 2. Installation: Install the specific version of the docker Automatic script installation (here is used here) Automatic script installat... 1. Installation 1. Go to the official website to download the latest version https://nodejs.org/en/ Choose to download and upload or use wget to download directly 2.