We use n module from npm to upgrade node to the stable version
sudo npm cache clean -f
sudo npm install -f n
sudo n stable
To upgrade to the latest version (no stable version)
sudo n latest
Fix PATH /usr/bin/node
sudo apt-get install --reinstall nodejs-legacy
To undo n installation
sudo n rm x.y.z # replace x.y.z with version of Node installed
sudo npm uninstall -f n
Found in David Walsh blog.