Raspberry Pi

How to Uninstall Node.js from Raspberry Pi

Node.js is a cross-platform server environment that lets users run JavaScript code outside a browser. It is a widely used tool for web-based development projects since it runs the V8 JavaScript engine (Core of Google Chrome), allowing developers to build scalable network applications easily.

Besides Node.js advantages, some developers don’t consider it an ideal choice for developing web-based applications, especially for those from different programming backgrounds. In that case, they want to remove this tool from their systems. If, in any case, you want to do the same, you can follow this article for detailed guidance on how to uninstall Node.js from the Raspberry Pi Linux.

How to Uninstall Node.js from Raspberry Pi

Node.js comes preinstalled on most Linux distributions and the same is the case for Raspberry Pi as well. However, some users install the updated versions of Node.js through the “n” module or Node Version Manager (NVM). All these methods are independent; thus, a single removal command won’t remove Node.js from the system.

Let’s talk about uninstalling Node.js from all those methods.

Method 1: Remove Node.js from Raspberry Pi Repository

If you want to remove the Node.js application from your Raspberry Pi system completely, you can simply use the following command:

$ sudo apt --purge remove nodejs -y

To confirm Node.js is successfully removed, follow the below-mentioned command:

$ node -v

Method 2: Remove Node.js from n module

The “n” module is a Node Package Manager (NPM) module that allows Raspberry Pi users to update Node.js versions on their systems. The users can simply execute the following command to install the “n” module through NPM:

$ sudo npm install -g n

Later, they can install the updated Node.js version through the following command:

$ sudo n latest

If you have followed the same method for Node.js installation, then executing the above “apt removal” command won’t remove the Node.js from your system. You have to follow the below-mentioned command to uninstall Node.js from the Raspberry Pi system from this method.

$ sudo n uninstall stable

Add “y” to confirm uninstalling Node.js latest version from your Raspberry Pi system.

You can confirm the removal through the following command:

$ node -v

You can also use the following command to remove the Node.js directory from your system:

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

Method 3: Remove Node.js from NVM

Node Version Manager (NVM) is another effective way that allows Raspberry Pi users to install the latest version of Node.js and replace it with the old version.

NVM can be installed through the following command:

$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash

To install Node.js latest stable version, the following command can be used:

$ nvm install stable

If you followed the above NVM method for Node.js installation and want to remove it now, you first must deactivate NVM through the following command:

$ nvm deactivate

Then use the following command to uninstall Node.js version on Raspberry Pi system.

To confirm the Node.js removal, run the version command again.

$ node -v

In this way, you can uninstall the Node.js version from your Raspberry Pi system.

Conclusion

Node.js can be uninstalled from the official Raspberry Pi repository through the “apt –purge remove” command. However, those users who installed Node.js from the NPM “n” module can remove it through the “n uninstall” command. If someone chooses the NVM method for Node.js installation, they must deactivate NVM first and then uninstall the Node.js version through the “nvm uninstall” 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.