← coderrocketfuel.com

How To Uninstall Node.js On Ubuntu 19.04

How do you uninstall or remove the Node.js software from your Ubuntu 19.04 machine?

Depending on the version you want to remove from your system, you can use either Apt or 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 do both methods.

Let's get started!

Table Of Contents

Uninstall Using Apt

If you want to uninstall the Ubuntu 19.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.

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 Ubuntu's autoremove command. Whenever an application is installed on Ubuntu 19.04, the system will also automatically install any other software that the application depends on.

The autoremove command 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 14.17.6

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:

nvm current

If the version you want to uninstall is the current active version, you need to first deactivate it with this Nvm command:

nvm deactivate

Now you can uninstall that current version with the same uninstall command specified above:

nvm uninstall 14.17.6

And that version of Node.js will be removed from your machine.