Locate the Binaries
The first step toward uninstalling NodeJS in Ubuntu is finding the folder that houses its binaries. That will enable you to confirm whether NodeJS was uninstalled.
which node
find $(echo $PATH | sed ‘s/: / /g’) -name “node” ---- (Remove space after the : dots)
Uninstall NodeJS
After locating the node binaries, the next step is to remove them.
Option 1: Remove the Path
sudo rm /usr/bin/node
Option 2: Uninstall with the apt or apt-get Command
sudo apt-get remove nodejs
Option 3: Remove All Packages with the purge Command
sudo apt-get purge nodejs
or
sudo apt-get purge – auto-remove nodejs
Let’s reinstall NodeJS