Completely uninstall NodeJS and NPM in Ubuntu

Completely uninstall NodeJS and NPM in Ubuntu

Completely uninstall NodeJS and NPM in Ubuntu

NPM Oct 29, 2022

Problem:
Unable to uninstall NodeJS and NPM

Platform:
Ubuntu

Solution:
It is preferable to delete NodeJS and its modules manually since installation leaves a large number of files, links, and modules behind, which causes issues when reconfiguring another version of NodeJS and its modules.

Execute the following commands to delete the files:

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
rm -rf ~/.npm
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*

It works like charm.

Suggestion:
To install different versions of NodeJS and NPM, use NVM.
Here's the link to the package.

https://github.com/nvm-sh/nvm#install--update-script

Thanks!

Tags

Anurag Deep

Logical by Mind, Creative by Heart