How to Uninstall NodeJS on Debian 9
How do you uninstall or remove the Node.js software from your Debian 9 machine?
Depending on the version you want to remove from your system, you can use either
Aptmethod will remove all traces of Node.js from your machine and
Nvmwill allow you to uninstall specific versions of the software.
In this article, we'll show you how to do both methods.
Let's get started!
Table of Contents
Uninstall Using Apt
If you want to uninstall the Debian 9 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.
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.
An additional and optional step is to use Debian's
autoremovecommand. Whenever an application is installed on Debian 9, the system will also automatically install any other software that the application depends on.
autoremovecommand will remove those dependencies that were added with applications (Node.js in this case) and that isn't used by anything else in the system.
This is what the command looks like:
$ sudo apt autoremove
After that command finishes, that'll 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 the yellow text with your version):
$ nvm uninstall 10.16.3
Once that command finishes, that version of Node.js will be removed.
You can also use
Nvmto 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:
$ nvm current
If the version you want to uninstall is the current active version, you need to first deactivate it with this
$ nvm deactivate
Now you can uninstall that current version with the same
uninstallcommand 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 Debian 9 machine using either the
Nvmcommands. Depending on your circumstances, one or either method will better suit your needs.
Thanks for reading and happy coding!