Raspberry Pi

How Can I Completely Uninstall Nodejs and NPM in Raspberry Pi

Node.js is an open-source, cross-platform JavaScript run-time environment for creating diverse varieties of applications and tools on the system. While NPM is a node package manager for Node.js that enables users to install Node.js based packages on the system. It also helps install different versions of Node.js on the system according to users’ needs.

Node.js and NPM help create different web-based applications; however, not all developers prefer them as an ideal choice for developing web applications. For this purpose, if a user has already installed Node.js and NPM on the Raspberry Pi system, they can follow this article’s guidelines that help them remove both Node.js and NPM from the system.

Completely Uninstall Nodejs and NPM in Raspberry Pi

There are multiple ways to install both Node.js and NPM on the Raspberry Pi system, thus, the methods to remove them are different. These methods include:

Method 1: Uninstall Node.js and NPM from Raspberry Pi Repository

Installing Node.js and NPM directly through the Raspberry Pi repository is the most straightforward method. If you are the one who installed Node.js and NPM from the Raspberry Pi repository, you can uninstall or completely remove them from the system by simply executing the following command:

$ sudo apt purge --autoremove nodejs npm -y

Method 2: Uninstall Node.js and NPM By Deleting Source Files from the System

You can also completely uninstall Node.js and NPM from the Raspberry Pi system by removing their source directory. For this purpose, first you have to find the location where Node.js and NPM is installed and you can find it using the following commands:

$ which node

$ which npm

After finding the location of Node.js and NPM on the Raspberry Pi system, you can simply remove these directories using the following command:

$ sudo rm -rf /usr/bin/node /usr/bin/npm

You can confirm remove of Node.js and NPM through following commands:

$ node -v

$ npm -v

The above commands ensure that both Node.js and NPM are successfully removed from the system.

Conclusion

The guidelines above show you two different ways to completely remove Node.js and NPM from the Raspberry Pi system. These methods include removing them through the “apt purge –autoremove” command or removing the source directories of both Node.js and NPM through the “rm -rf” command.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.