Closed kallja closed 2 years ago
Thanks, @kallja. What's the expected behavior when you switch to a different version or uninstall said version? What happens when you uninstall nvm itself?
The proposed functionality should only affect what happens on install of a Node version. If there are default packages defined, those packages will be installed (using npm
) after the Node version has been installed and activated. Installing a global Node module this way is exactly the same as installing that module manually using npm install -g MODULE_NAME
after nvm install VERSION
.
Added benefit of this approach vs explicit installation in (automation scripts) is that nvm
only calls npm install
when a new Node version is installed. Thanks to great performance, requests to install pre-existing Node versions run quickly without taking unnecessary actions.
As to the specific questions, this proposed behavior doesn't change the current behavior in any way.
Thank you for all the info, @kallja. I'd like to propose an alternative solution to this problem via Fish events.
Say we fire an nvm_node_install
event whenever a Node version is installed for the first time. Then you can npm install or react to this event in any way you like. For example, in config.fish:
function npm_install_default_packages --on-event nvm_node_install
npm install --global yarn
end
What do you think?
I went ahead and decided to add this. 🎉 Thank you, @kallja!
I'm glad I was able to help out one tiny bit. Thank you for including this change!
nvm
has support for Default Packages, where one can define a set of global packages that are installed during each install of anode
version.I'd love to see this introduced into nvm.fish. I frequently need to have
yarn
, for example, installed into my fresh node environments.In fact, I already implemented this for myself. A PR is soon to follow for your consideration.