How to properly upgrade node using nvm

You can more simply run one of the following commands:

Latest version:

nvm install node --reinstall-packages-from=node

Stable (LTS) version: (if currently in use)

nvm install "lts/*" --reinstall-packages-from="$(nvm current)"

This will install the appropriate version and reinstall all packages from the currently used node version.

This saves you from manually handling the specific versions.


Kudos to @m4js7er for commenting about the LTS version.


This may work:

nvm install NEW_VERSION --reinstall-packages-from=OLD_VERSION

For example:

nvm install 6.7 --reinstall-packages-from=6.4

then, if you want, you can delete your previous version with:

nvm uninstall OLD_VERSION

Where, in your case, NEW_VERSION = 5.4 OLD_VERSION = 5.0

Alternatively, try:

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