How can I completely uninstall nodejs, npm and node in Ubuntu 14.04

lpares12 picture lpares12 · Sep 6, 2015 · Viewed 332.4k times · Source

I wrongly installed "node" by running the command sudo apt-get install node And later I installed nodejs (v0.10.37). I tried to update to v0.12 with npm but it keeps saying 0.10.37 when I run nodejs -v. Also, I can't use the node command since I wrongly installed the other node thing before.

I think the main problem is that I still have the wrong node package and installing nodejs-legacy doesn't work.

Also the npm install command works and creates the folder with the files but my app still says that the libraries are missing.

Answer

Raja picture Raja · Nov 26, 2015
sudo apt-get remove nodejs
sudo apt-get remove npm

Then go to /etc/apt/sources.list.d and remove any node list if you have. Then do a

sudo apt-get update

Check for any .npm or .node folder in your home folder and delete those.

If you type

which node

you can see the location of the node. Try which nodejs and which npm too.

I would recommend installing node using Node Version Manager(NVM). That saved a lot of headache for me. You can install nodejs and npm without sudo using nvm.