As some of you already said, the easiest way is to update Node.js through the Node.js package manager, npm. If you are a Linux (Debian-based in my case) user I would suggest to add these lines to your .bashrc
file (in home directory):
function nodejsupdate() {
ARGC=$#
version=latest
if [ $ARGC != 0 ]; then
version=$1
fi
sudo npm cache clean -f
sudo npm install -g n
sudo n $version
}
Restart your terminal after saving and write nodejsupdate
to update to the latest version of Node.js or nodejsupdate v6.0.0
(for example) to update to a specific version of Node.js.
BONUS: Update npm (add these lines to .bashrc
)
function npmupdate() {
sudo npm i npm -g
}
After restarting the terminal write npmupdate
to update your node package manager to the latest version.
Now you can update Node.js and npm through your terminal (easier).