Updated February 2021
Just go to the official Node.js site (nodejs.org), download and execute the installer program.
It will take care of everything and with a few clicks of 'Next' you'll get the latest Node.js version running on your machine. Since 2020 it's the recommended way to update NodeJS. It's the easiest and least frustrating solution.
Pro tips
NodeJS installation includes NPM (Node package manager).
To check your NPM version use npm version
or node --version
.
If you prefer CLI, to update NPM use npm install -g npm
and then npm install -g node
.
For more details, see the docs for install
command.
Keep an eye on NodeJS blog - Vulnerabilities so you don't miss important security releases. Keep your NodeJS up-to-date.
Operating systems supported by Node.js: Windows, Linux, MacOS, SunOS, IBM AIX.
For Docker users, here's the official Node.js image.
Troubleshooting for Windows:
If anyone gets file error 2502/2503 like myself during install, run the .msi via Administrator command prompt with command
msiexec /package [node msi]
If my answer is helpful, don't forget to upvote it
(here is the original answer by Anmol Saraf, upvote it too)