So whenever I upgrade to another Node version, I have to remember reinstalling all the global packages again which is kinda inconvenient. I know this is apparently by design, but am wondering if we can provide a better way to help this situation?
I just hopped into the issues to find this out myself. Seems I lose most of the benefit nvm provides if all my packages don鈥檛 have an easy migration path. Since I鈥檓 not generally hacking on node, rather using npm for front-end stuff like grunt and yo I have a little looser tolerances for not needing to know how the bare-metal has changed.
Rbenv got a default gems plugin, which are installed when a newer version of ruby is installed. So maybe a file default-packages in the NVM_DIR can be checked after installation?
There's a nvm copy-packages <version> that does this, but it's buggy because it gets the list of packages by doing:
`nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f 8 | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "`
That first cut assumes that $ROOT is exactly 6 levels deep (which is the case if you have nvm in something like /home/user/nvm)
nvm use 0.10.24; nvm copy-packages 0.10.23 is the way to do this.
Most helpful comment
nvm use 0.10.24; nvm copy-packages 0.10.23is the way to do this.