To uninstall node.js from Ubuntu server.
Here are some commands to run.
To remove the node package but keep the configuration file run :
sudo apt-get remove nodejs
To remove both the node package and it's configuration files run :
sudo apt-get purge nodejs
The final step is to remove any unused files and free up disk space. To do this we run
sudo apt-get autoremove
We have successfully uninstalled node.js and freed up space.