Question: migrate global npm packages
Hello,
Thank you for this great tool!
I was wondering, what's the "recommended" way to migrate globally installed npm packages when moving from one version to another?
Thanks again!
I second this, can we push for this to happen?
I believe the nvm way of doing this was to:
nvm use <node version>nvm copy-packages <node version that has the global packages you want to migrate from>nvmwill then migrate those global packages (with the same versions) to the node version you're using.
I'd love to see fnm having this capability as well! <3
It’s nvm reinstall-packages Y since that’s a more accurate name :-) (and nvm install X --reinstall-packages-from=Y)
It will reinstall packages as well as copy over symlinks (from npm link).
I use this for migrating global packages (assuming we are currently on the newer version):
fnm_upgrade () {
fnm exec --using=$1 npm ls --global --json \
| jq -r '.dependencies | to_entries[] | .key+"@"+.value.version' \
| xargs npm i -g
}
# Usage:
$ fnm_upgrade 18.4
Has anyone managed to create a script for windows PS?
I switched to pnpm for global packages, which sort of solved this issue for me as pnpm keeps packages in a global folder, not tied to a particular version of node. Might be helpful for someone else as well.
That’s surprising since global packages must be tied to a particular version of node, since installed and compiled packages can differ based on the node version.
Is this a dupe of https://github.com/Schniz/fnm/issues/139?
I made a suggestion to add a hooks system, which I think could be used to implement this in https://github.com/Schniz/fnm/issues/1060