Update Node.js version to the latest LTS or stable version with nvm

I use the following command to update Node.js to the latest LTS version with nvm:

nvm install --lts --reinstall-packages-from=current

If you use the stable version, use the follows:

nvm install stable --reinstall-packages-from=current

These commands install the latest LTS/stable version of Node.js, and install global packages that are installed in the Node.js version that is currently being used.

Also use nvm uninstall to uninstall the outdated version if desired.