Node.js on Ubuntu

  1. sudo apt update
  2. sudo apt install nodejs
  3. node -v
  4. sudo apt install npm

You can uninstall Node.js using apt or nvm, depending on how it was installed. To remove the version from the system repositories, use apt remove:

sudo apt remove nodejs

By default, apt remove retains any local configuration files that were created since install. If you don’t want to save the configuration files for later use, use apt purge:

sudo apt purge nodejs

To uninstall a version of Node.js that you installed using nvm, first determine whether it is the current active version:

nvm current

If the version you are targeting is not the current active version, you can run:

nvm uninstall node_version

Output
Uninstalled node node_version

This command will uninstall the selected version of Node.js.

If the version you would like to remove is the current active version, you’ll first need to deactivate nvm to enable your changes:

nvm deactivate

Now you can uninstall the current version using the uninstall command used previously. This removes all files associated with the targeted version of Node.js.