If you wish to uninstall NodeJS from your Ubuntu system, run the command below.
sudo apt-get remove nodejs
The command will remove the package but retain the configuration files. To remove both the package and the configuration files run:
sudo apt-get purge nodejs
As a final step, you can run the command below to remove any unused files and free up the disk space
sudo apt-get autoremove
Great! We have successfully installed and tested the installation of NodeJS. We also learned how to uninstall NodeJS from Ubuntu and clean up space.