This article will illustrate all possible methods to remove NodeJS from Ubuntu:
- Method 1: Remove NodeJS | Installed From APT
- Method 2: Remove NodeJS Directory | Installed From Source Code
Method 1: Remove NodeJS | Installed From APT
One of the common methods to uninstall/remove any package if it is installed using the APT package manager. Follow the below-mentioned procedure to remove the NodeJS package with all dependencies and configuration files:
Remove NodeJS Package
To remove the Node.js package through the apt package manager, use the “remove” command. For instance, specify the “nodejs” package with the “sudo” privileges:
$ sudo apt remove nodejs
It removes the NodeJS package from the Ubuntu system.
Remove All Configuration Files
To remove all configuration files, use the “purge” utility by specifying the package name, i.e., nodejs:
$ sudo apt purge nodejs
The output shows that the “nodejs” package along with all configuration files have been removed.
Remove All Dependencies
To remove all dependencies of the specified package, use the “autoremove” option. For instance, specify the “nodejs” package name with the “sudo” privileges:
$ sudo apt autoremove nodejs
The output represents that all the dependent files have been removed from the system.
Method 2: Remove NodeJS Directory | NodeJS Installed From Source
If the NodeJS is installed from the source code then it can be removed by following this method. In this method, users manually remove the “node” directory after locating the complete directory. For this, the “which” command is utilized by specifying the “node” directory in the below command:
$ which node
The above command provides the complete “/usr/bin/node” path.
After locating the path, use the “rm” command to remove the complete directory by specifying the “/usr/bin/node” path:
$ sudo rm /usr/bin/node
The output shows that the “node” directory has been removed successfully.
To remove NodeJS from Ubuntu, use the APT package manager and source directory. In the APT package manager, users can utilize the “remove”, “purge” and “autoremove” to remove packages along with all dependent and configuration files. In addition, the “rm” command is beneficial to remove the “node” directory manually.
This article has covered all possible methods to remove NodeJS from Ubuntu.