Search code examples
node.jsnpmnvmpackage-management

How to properly upgrade node using nvm


Is it possible to upgrade node right in place, instead of manually installing the latest stable version?

I have installed node.js version 5.0 with nvm, but now I want to update it to 5.4. I'm trying to avoid having to manually reinstall all of my global packages (e.g. by running npm install -g grunt-cli bower yo yoman-angular-generator blabla blablablabla...).


Solution

  • 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 node --reinstall-packages-from=current
    

    Or you can update to the last long-term support version with

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