Node.js on Ubuntu
How To Install Node.js on Ubuntu
- sudo apt update
- sudo apt install nodejs
- node -v
- sudo apt install npm
Removing Node.js
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.