Managing global npm packages when using nvm

UPDATE October 2020:

If you've already installed the desired Node version, according to the documentation this is also available:

nvm reinstall-packages <from-version>

Props to @rashi for pointing out the syntax above.


From the nvm help message:

nvm install [-s] <version>                Download and install a <version>, [-s] from source. Uses .nvmrc if available
    --reinstall-packages-from=<version>     When installing, reinstall packages installed in <node|iojs|node version number>
    --lts                                   When installing, only select from LTS (long-term support) versions
    --lts=<LTS name>                        When installing, only select from versions for a specific LTS line

The relevant flag is --reinstall-packages-from=<version>. Simply re-run your command (example):

$ nvm install v6.9.2 --reinstall-packages-from=v4.4.5

Tags:

Node.Js

Npm