How to Migrate npm Packages When Upgrading Node.js using nvm

I’m tinkering with Node.js and using the awesome tool nvm to manage versions. One thing I struggled with briefly was upgrading to the latest version of Node using nvm. When I did that, all of my npm packages were gone which seemed to make sense since nvm installed the new version of Node in it’s own directory. So I manually reinstalled all of the npm packages I was using in the previous version. But I figured this couldn’t be the norm as it would drive devs crazy if there were no easy migration path.

Well, sure enough there is and I’m just noting the command syntax here since the nvm Github page doesn’t explicitly mention it. Here’s an example:

nvm install v0.12.7 --reinstall-packages-from=0.12.6

Notice you’re installing the newer version and asking to reinstall packages from an older version.

Might have to do a pull request on the Readme.md

Rey Bango