How to remove npm and NodeJS in ubuntu?
This article is on how to uninstall npm and nodejs completely in ubuntu. Use the below commands to uninstall the npm and nodejs.
So, Let's get started:
Step: 1 Open the terminal in Ubuntu
Open the terminal using Ctrl + Alt + T
or right-click and select open in terminal
.
Step: 2 Remove nodejs
The below command will remove nodejs.
sudo apt-get remove nodejs
Step: 2 Remove npm
To remove npm, use the below command.
sudo apt-get remove npm
Untile now, we just removed nodeJS and npm. To remove npm and nodejs completely, follow the following instructions.
Step: 3 Remove node list
Use the first command to open the directory which consists node lists. Remove all the node lists like nodesource.list
present in that folder.
cd /etc/apt/sources.list.d
sudo rm nodesource.list
Step: 4 Go to Home folder
cd ~
Step: 5 Check for .npm and .node folder and remove them
To list all the files, follow the following command.
ls -a
If there is folder with .npm, .node, or both, then delete them. Replace .npm
with .node
for node folder.
sudo rm -rf .npm
Now use the which
command to check if there is any files is available with names like node, nodejs, or npm. Replace npm
with the other two to check.
which npm
Congrats, the npm and nodes are removed completely.
Thank you for reading this article.