How do you uninstall node.js using the cmd line in linux?
21 Answers 21
For Ubuntu 12.04:
sudo apt-get remove nodejs
This will uninstall nodejs
as well as npm
.
-
10now these are the kind of answers i like... simple and to the point. thanks a bunch! worked like a charm for Ubuntu 12.04vijay– vijay2013年02月07日 22:14:28 +00:00Commented Feb 7, 2013 at 22:14
-
3This didn't remove the
.nmp
directory in my home directory~
. I removed it myself. Are there any other files or directories like that I need to remove to completely remove node and npm?teewuane– teewuane2015年02月05日 05:02:12 +00:00Commented Feb 5, 2015 at 5:02 -
1I had to run sudo apt-get -f install before running the remove command. Afterwards, it was removed successfully.irl_irl– irl_irl2015年04月09日 11:41:58 +00:00Commented Apr 9, 2015 at 11:41
-
2Worked for me on Lubunto 16.04. Woot!aero– aero2016年10月06日 18:37:08 +00:00Commented Oct 6, 2016 at 18:37
-
1Note to users new to Linux: replace 'apt-get' in the above command with 'dnf' if you are using Fedora/ Red Hat Enterprise Linux.Kdwk– Kdwk2020年09月06日 09:11:35 +00:00Commented Sep 6, 2020 at 9:11
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.
-
6You must know that Nodejs has npm as well if you do this you will end up with a mess to unistall npm or aany other package you install using itT04435– T044352015年09月03日 16:28:02 +00:00Commented Sep 3, 2015 at 16:28
-
Some people might need to run
which nodejs
as I did in Ubuntusethreidnz– sethreidnz2016年05月12日 23:54:15 +00:00Commented May 12, 2016 at 23:54 -
I did the same, now when I do
node -v
it shows nothing but the file and folder remains there under folder node. So its not removed fully!!Ankur Shah– Ankur Shah2016年07月20日 08:50:27 +00:00Commented Jul 20, 2016 at 8:50 -
@Jubair You cannot remove npm if you've already removed node, because npm needs node to run.Paul Allsopp– Paul Allsopp2018年01月05日 21:31:39 +00:00Commented Jan 5, 2018 at 21:31
-
2Removing a folder is, at least, dangerous and it doesn't guarantee the clean removal of a product. I would recommend avoiding applying this answer unless you have removed the product first and you find it leaves some files behind. You can remove the product cleanly by using the corresponding command as it has been explained in other answers of this thread.Lucky Brain– Lucky Brain2020年12月02日 16:43:40 +00:00Commented Dec 2, 2020 at 16:43
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
-
1will that remove npm and its installs?abe– abe2011年04月13日 13:46:17 +00:00Commented Apr 13, 2011 at 13:46
-
1Probably not. You are better off running
npm uninstall npm
to uninstall npm prior to uninstalling node.Justin Ethier– Justin Ethier2011年04月13日 13:48:35 +00:00Commented Apr 13, 2011 at 13:48 -
thats really odd it seemed to uninstall a bunch of files said it uninstalled but when i type node it still enters node mode...i rebooted the server to in case it was in ramabe– abe2011年04月13日 14:20:11 +00:00Commented Apr 13, 2011 at 14:20
-
Hmm... do you have to specify an installation prefix, to uninstall a version in a custom place such as your local home directory?Justin Ethier– Justin Ethier2011年04月13日 14:29:51 +00:00Commented Apr 13, 2011 at 14:29
-
If you'd removed sources and you have a fresh one, you need to run
./configure
thensudo make uninstall
. if you didn't specify--prefix
you don't need--prefix
nowGhominejad– Ghominejad2014年10月10日 15:07:50 +00:00Commented Oct 10, 2014 at 15:07
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!!!
-
This works! Forgotten I'd installed it with yum.
yum list installed | grep nodejs
to check. +1ourmandave– ourmandave2019年02月25日 02:21:16 +00:00Commented Feb 25, 2019 at 2:21 -
confirmed to be good on removing node 10, and installing node 12 on centos 7P Marecki– P Marecki2019年10月30日 06:26:23 +00:00Commented Oct 30, 2019 at 6:26
-
You saved my day! :)Catalin Halic– Catalin Halic2021年03月20日 20:03:32 +00:00Commented Mar 20, 2021 at 20:03
-
i tried with running this curl --silent --location rpm.nodesource.com/setup_12.x | sudo bash - and sudo yum -y install nodejs commands, but the installed version was v6.17.1 it was not 12Nithin– Nithin2021年09月22日 05:56:02 +00:00Commented Sep 22, 2021 at 5:56
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.
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.
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.
-
This helped remove an older, orphaned version of npm. Helpful to also run
hash -r
afterwards.scader– scader2022年11月07日 17:45:54 +00:00Commented Nov 7, 2022 at 17:45
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.
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
-
4I found an official
rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*
removal command @ https://docs.npmjs.com/misc/removing-npm, I'm not sure if it's logically equivalent to your command, I'll try it though (it might require asudo
, too).Big Rich– Big Rich2015年04月23日 00:35:47 +00:00Commented Apr 23, 2015 at 0:35 -
On ubuntu 14.04 sudo apt-get remove nodejs helps me to sort out this problem.Gurjit– Gurjit2015年12月25日 18:31:56 +00:00Commented Dec 25, 2015 at 18:31
-
@BigRich I'm not quite sure what you mean by "logically", but your bygone reference, expands to totally different directories. He should've explicitly prefixed the directories with a forward slash too or directory of some kind.kqvanity– kqvanity2022年09月04日 07:53:09 +00:00Commented Sep 4, 2022 at 7:53
-
@polendina, been 7 years, instead of 'logically' I probably meant simply 'not exactly the same as'. As you state, my command, directly from NPMJS themselves, expands to a different set of directory locations, for a NodeJS installation relative to
/usr/local
. I believe that the OP, and others of a technical standard sufficient to consider the installation and subsequent removal of NodeJS from their systems, would in fact be able to 'tweak' the command I offered in good faith, to the particular needs and layout of their own system(s), as to not use it 'blindly' - I offered a 'hint'.Big Rich– Big Rich2022年11月18日 04:29:52 +00:00Commented Nov 18, 2022 at 4:29
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
I think this works, at least partially (have not investigated):
nvm uninstall <VERSION_TO_UNINSTALL>
eg:
nvm uninstall 4.4.5
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'
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
-
Worked with Ubuntu 14.04 LTS as wellShail– Shail2015年04月18日 01:24:45 +00:00Commented Apr 18, 2015 at 1:24
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
-
Follow the first steps to install it. Then added to the pathT04435– T044352016年05月10日 08:32:51 +00:00Commented May 10, 2016 at 8:32
-
2Brew as a terminal command can be used in OSX or Linux based systems. The only difference between the two system is that brew the original is for OSX and LinuxBrew is a version of it for Linux. The one I'm talking here is LinuxBrew. So once more if you follow the instructions you could use it in Linux based systems. ThanksT04435– T044352016年05月11日 06:12:41 +00:00Commented May 11, 2016 at 6:12
-
I'm not sure about installing an additional package manager that might cause conflict by overwriting the same directories, or outright be nullified by its low priority in its binaries invocation, behind the formerly dangling node/npm versions. Anyways, OP is asking for explicit removal solution, not a workaround!kqvanity– kqvanity2022年09月04日 08:05:27 +00:00Commented Sep 4, 2022 at 8:05
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
-
you do not need to the home directory FYI. And try to elaborate a bit further to make your answer more explanatoryb10n1k– b10n1k2021年10月30日 10:26:21 +00:00Commented Oct 30, 2021 at 10:26
-
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.2021年10月30日 10:26:56 +00:00Commented Oct 30, 2021 at 10:26
In addition to apt or yum removal, clean any residual files to avoid conflicts if you ever install a new version:
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/share/man/man1/node*
sudo rm -rf /usr/local/lib/dtrace/node.d
sudo rm -rf ~/.npm
sudo rm -rf ~/.node-gyp
sudo rm -rf /opt/local/bin/node
sudo rm -rf opt/local/include/node
sudo rm -rf /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*
For Centos 7 and 8
Remove NodeJS
sudo yum remove -y nodejs
sudo rm -rf /var/cache/yum
sudo rm /etc/yum.repos.d/nodesource*
sudo yum clean all
Remove residual files
whereis node
sudo rm -rfv /usr/bin/node /usr/local/bin/node /usr/share/man/man1/node.1.gz
sudo rm -rfv /usr/bin/npm /usr/local/bin/npm /usr/share/man/man1/npm.1.gz
sudo rm -rfv /usr/local/bin/npx
sudo rm -rfv /usr/local/lib/node*
sudo rm -rfv /usr/local/include/node*
sudo rm -rfv /usr/lib/node_modules/
In Linux Debian 11:
$ sudo apt remove nodejs
For my case, I wanted to remove both nodejs
and npm
:
$ sudo apt remove nodejs npm
Just remove these files. No need to do anything else.
rm -rf ~/.nvm
rm -rf ~/.npm
rm -rf ~/.bower
for Linux Debian I wanted to remove node , npm and nvm so I did
nvm uninstall v14.21.3
. Do same for each version
and do nvm deactivate
and then uninstall the currently used version
in /home/user
directory (that is where nvm was installed for me)
rm -rf node_modules
rm -rf .npm
rm -rf .npmrc
( you can leave this but I removed it)
rm -rf .nvm
sudo nano .bashrc
and then remove these lines
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Another take:
sudo apt remove nodejs
sudo rm -rf /usr/lib/node_modules/npm
sudo rm -rf /usr/local/lib/node_modules/
sudo rm -f /usr/share/man/man1/npm-*
sudo rm -f /usr/share/man/man1/npm.1
sudo rm -f /usr/share/man/man5/npm-*
sudo rm -f /usr/share/man/man5/npmrc.5
sudo rm -rf /root/.npm
rm -rf $HOME/.npm
rm -rf $HOME/.node_repl_history
From there, if you have locate
installed:
sudo updatedb
locate -i "npm" | grep -v ignore | grep -v opam
nodejs
and npm
are uninstalled.