How do you uninstall or remove the Node.js software from your Ubuntu 18.04 machine?
Depending on the version you want to remove from your system, you can use either the Advanced Packaging Tool (Apt) or Node.js Version Manager (Nvm). The
Apt method will remove all traces of Node.js from your machine and
Nvm will allow you to uninstall specific versions of the software.
In this article, we'll show you how to use both methods.
Let's get started!
Uninstall Using Apt
If you want to uninstall the Ubuntu 18.04 distribution stable version using
Apt, execute this command in a terminal:
sudo apt remove nodejs
When you execute that command, the Node.js package will be removed, but your configuration files will remain on your system. These configuration files may be of use to you later on if you decide to install Node.js again.
It's recommended that you keep them on your system.
But if you don't want to keep the configuration files, you can remove them with this command:
sudo apt purge nodejs
This command will remove both the package and any configuration files on your machine that are related to Node.js.
An additional and optional step is to use Ubuntu's
autoremove command. Whenever an application is installed on Ubuntu 18.04, the system will also automatically install any other software that the application depends on.
autoremove command will remove those dependencies that were added with applications (Node.js in this case) and that aren't used by anything else in the system.
This is what the command looks like:
sudo apt autoremove
After that command finishes, that will remove all traces of Node.js from your machine.
Uninstall Specific Versions Using Nvm
If you used the Nvm (Node.js Version Manager) software to manage the use of multiple different versions of Node.js, you can remove a specific version with this command (replace
10.16.3 with your version):
nvm uninstall 10.16.3
Once that command finishes, that version of Node.js will be removed.
You can also use
Nvm to remove the current version of Node.js being used.
First, make sure the version you want to remove is the currently active version with this command:
If the version you want to uninstall is the current active version, you need to first deactivate it with this
Now you can uninstall that current version with the same
uninstall command specified above:
nvm uninstall 10.16.3
And that version of Node.js will be removed from your machine.
In this article, we gave you two different ways to remove Node.js from your Ubuntu 18.04 machine using either the
Nvm commands. Depending on your circumstances, one or both methods will suit your needs.
Thanks for reading and happy coding!