For Ubuntu 12.04:
sudo apt-get remove nodejs
This will uninstall nodejs as well as npm.
For Ubuntu 12.04:
sudo apt-get remove nodejs
This will uninstall nodejs as well as npm.
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.
Uninstall node js
What's the best way to remove Node.js, NPM, and all related packages from Ubuntu?
How do I completely remove Node and NPM?
how to uninstall
Videos
As seen from the output of:
sudo apt-get purge nodejs
it is only removing node related packages i.e. relevant packages, nothing more.
On the other hand, when you do:
sudo apt-get purge --auto-remove nodejs
it is essentially doing:
sudo apt-get purge nodejs
sudo apt-get autoremove
and the removal of the gyp, linux-headers-4.4.0-18-generic etc packages are actually triggered by autoremove as they were installed as dependencies and no longer needed by any installed package, presumably because the main package has been removed.
So it is perfectly fine in this context to run:
sudo apt-get purge --auto-remove nodejs
If you are too paranoid, you can do it in two steps: first purge nodejs:
sudo apt-get purge nodejs
and then remove the orphan dependencies (till now, if any):
sudo apt-get autoremove
To remove node js, npm and node_modules from Ubuntu, you need to remove containers also which are at different locations in Ubuntu. These could be as:
/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
I have posted the procedure to remove NodeJS on my blog: AMCOS IT Support For Windows and Linux: To completely uninstall node js from Ubuntu.
First of all you need to run the following command from command terminal as sudo.
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_modulesRemove node or node_modules directories from /usr/local/lib with the help of following command.
sudo rm -rf /usr/local/lib/node*Remove node or node_modules directories from /usr/local/include with the help of following command.
sudo rm -rf /usr/local/include/node*Remove any node file or dir from /usr/local/bin with the help of following command.
sudo rm -rf /usr/local/bin/node*Go to home directory and remove any node or node_modules directory, if exists.