Uninstall Node.JS using Linux command line?

Linuxnode.jsCommand Line

Linux Problem Overview


How do you uninstall node.js using the cmd line in linux?

Linux Solutions


Solution 1 - Linux

In Ubuntu 12.04 simply type this

$ sudo apt-get remove nodejs

It will uninstall nodejs and npm as well simple.

Solution 2 - Linux

Edit: If you know which package manager was used to install, it is best to uninstall with the same package manager. Examples for apt, make, yum are in other answers.

This is a manual approach:

Running which node will return something like /path/bin/node.

Then run cd /path

This is all that is added by Node.JS.

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

Now the only thing I don't know about is npm and what it has installed. If you install npm again into a custom path that starts off empty, then you can see what it adds and then you will be able to make a list for npm similar to the above list I made for node.

Solution 3 - Linux

If you installed from source, you can issue the following command:

sudo make uninstall

If you followed the instructions on https://github.com/nodejs/node/wiki to install to your $HOME/local/node, then you have to type the following before the line above:

./configure --prefix=$HOME/local/node

Solution 4 - Linux

Sorry the answer of George Bailey does work very fine when you want absolutely remove the node from your machine.

This answer is referred from : @tedeh https://github.com/nodesource/distributions/issues/486

If you wanna install a new version of node you have to use the code below

sudo rm -rf /var/cache/yum
sudo yum remove -y nodejs
sudo rm /etc/yum.repos.d/nodesource*
sudo yum clean all

And add new nodejs version to "yum" an new version of node

#using this command for Node version 8
curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -

#using this command for Node version 10
curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -

Install nodejs

sudo yum -y install nodejs

I hope it gonna help you guy!!!

Solution 5 - Linux

To uninstall node I followed the accepted answer by @George, as I no longer have the sources, but before doing so I ran:

sudo npm rm npm -g

That seemed to get rid of npm from the system directories such as /usr/bin/npm and /usr/lib/npm. I got the command from here. I then found a ~/.npm directory, which I deleted manually. Honestly I don't know if every trace of npm has been removed, but I can't find anything else.

Solution 6 - Linux

If you installed node using curl + yum:

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

Then you can remove it using yum:

sudo yum remove nodejs

Note that using the curl script causes the wrong version of node to be installed. There is a bug that causes node v6.7 to be installed instead of v4.x intended by the path (../setup_4.x) used in the curl script.

Solution 7 - Linux

This is better to remove NodeJS and its modules manually because installation leaves a lot of files, links and modules behind and later it create problems while we reconfigure another version of NodeJS and its modules. Run the following commands.

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 


sudo rm -rf /usr/local/lib/node*     
sudo rm -rf /usr/local/include/node*         
sudo rm -rf /usr/local/bin/node*

and this done.

A step by step guide with commands is at http://amcositsupport.blogspot.in/2016/07/to-completely-uninstall-node-js-from.html

This helped me resolve my problem.

Solution 8 - Linux

I think Manoj Gupta had the best answer from what I'm seeing. However, the remove command doesn't get rid of any configuration folders or files that may be leftover. Use:

sudo apt-get purge --auto-remove nodejs

The purge command should remove the package and then clean up any configuration files. (see this question for more info on the difference between purge and remove). The auto-remove flag will do the same for packages that were installed by NodeJS.

See the accepted answer on this question for a better explanation.

Although don't forget to handle NPM! Josh's answer covers that.

Solution 9 - Linux

The answer of George Bailey works fine. I would just add the following flags and use sudo if needed:

 sudo rm -rf bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node

Solution 10 - Linux

if you want to just update node, there's a neat updater too

https://github.com/creationix/nvm

to use, >git clone git://github.com/creationix/nvm.git ~/.nvm > >source ~/.nvm/nvm.sh > >nvm install v0.4.1

Solution 11 - Linux

If you have yum you could do:

yum remove nodesource-release* nodejs

yum clean all

And after that check if its deleted:

rpm -qa 'node|npm'

Solution 12 - Linux

after installing using the "ROCK-SOLID NODE.JS PLATFORM ON UBUNTU" script, i get this output. Which tells you how to uninstall nodejs.

> Done. The new package has been installed and saved to > > /tmp/node-install/node-v0.8.19/nodejs_0.8.19-1_i386.deb > > You can remove it from your system anytime using: > > dpkg -r nodejs

Solution 13 - Linux

Best way to go around this is to do it right from the BEGINNING:

INSTALL BREW

#HERE IS HOW: PASTE IN TERMINAL

sudo apt-get install build-essential curl git m4 ruby texinfo libbz2-dev libcurl4-openssl-dev libexpat-dev libncurses-dev zlib1g-dev

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)"

Then at the end of your .bashrc file(In your home directory press Ctrl + H)

export PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"

Then restart terminal so the modification to .bashrc are reloaded

TO INSTALL NODE

brew install node

TO CHECK VERSION

node -v
npm -v

TO UPDATE NODE

brew update
brew upgrade node

TO UNINSTALL NODE

brew uninstall node

Solution 14 - Linux

I think this works, at least partially (have not investigated):

nvm uninstall <VERSION_TO_UNINSTALL>

eg:

Solution 15 - Linux

To Remove nodejs installed in centos 8: From your home directory, run the below command

sudo yum remove nodejs

Enter y to confirm your command

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionabeView Question on Stackoverflow
Solution 1 - LinuxManoj GuptaView Answer on Stackoverflow
Solution 2 - Linux700 SoftwareView Answer on Stackoverflow
Solution 3 - LinuxJustin EthierView Answer on Stackoverflow
Solution 4 - LinuxTran Nhut LeView Answer on Stackoverflow
Solution 5 - LinuxJoshView Answer on Stackoverflow
Solution 6 - LinuxSaheedView Answer on Stackoverflow
Solution 7 - LinuxAmit MalikView Answer on Stackoverflow
Solution 8 - LinuxEuthyphroView Answer on Stackoverflow
Solution 9 - LinuxYaki KleinView Answer on Stackoverflow
Solution 10 - LinuxspencercoolyView Answer on Stackoverflow
Solution 11 - LinuxAdem DinarevićView Answer on Stackoverflow
Solution 12 - LinuxChristopher GrayView Answer on Stackoverflow
Solution 13 - LinuxT04435View Answer on Stackoverflow
Solution 14 - LinuxWill BricknerView Answer on Stackoverflow
Solution 15 - LinuxSAMUEL ODIKORView Answer on Stackoverflow