Unable to uninstall NodeJS and NPM
It is preferable to delete NodeJS and its modules manually since installation leaves a large number of files, links, and modules behind, which causes issues when reconfiguring another version of NodeJS and its modules.
Execute the following commands to delete the files:
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/share/man/man1/node*
sudo rm -rf /usr/local/lib/dtrace/node.d
rm -rf ~/.npm
rm -rf ~/.node-gyp
sudo rm -rf /opt/local/bin/node
sudo rm -rf /opt/local/include/node
sudo rm -rf /opt/local/lib/node_modules
sudo rm -rf /usr/local/lib/node*
sudo rm -rf /usr/local/include/node*
sudo rm -rf /usr/local/bin/node*
It works like charm.
To install different versions of NodeJS and NPM, use NVM.
Here's the link to the package.