-
-
Notifications
You must be signed in to change notification settings - Fork 750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persist global npm installs #364
Conversation
19059a2
to
30e5cc2
Compare
I think this is a great addition; however, it is extremely slow to copy every single global module installed. For this reason, I think persisting a global module should be opt-in. For example: n 0.11.1 # install v0.11.1
npm install --global [email protected]
yo --version # 1.1.0
n persist yo # persist the current `yo` version for this version of Node
n latest # install v6.3.1
npm update --global yo
yo --version # 1.8.4
n persist yo # persist the current `yo` version for this version of Node
n 0.11.1 # switch back to v0.11.1
yo --version # 1.1.0 There could be a similar command to unpersist. What do you think about this? |
I think making it opt in is fine. I feel that adding a command to persist once or to toggle is a bit much. Instead I'm thinking setting an environment variable that if set persists global modules is a good solution. For people that want to persist their global installs I believe that they would want this to apply to all versions managed by Does adding an environment variable sound sufficient? |
I just switched from homebrew's node to having Just in case it's helpful... I expected that each version of node that I don't know if this is a completely ridiculous suggestion. I just wanted to share my point of view as a relative newcomer, in case it's useful. Thanks for all your hard work! |
@JamesChevalier I think isolating As such, my main concern is that a solution compensating for both user's needs would be
If we are able to come up with a solution that serves both types of users, I would be all for implementing it! If not, making this isolated Thanks for sharing your thoughts! Community input is what makes good open-source software great. 😄 |
what about that? |
What about what, @Kikobeats? |
30e5cc2
to
b0ecf57
Compare
Hmm, what's the state of this pr? |
This is interesting, but I do not think adding more files to the install is a good fit for I think a lighter weight approach to achieve the separation would be to symlink into nvh/versions from the install destination instead of copying, but that isn't something I plan to do either. Feel free to open a new issue if this comes up again, with new information and renewed interest. Thank you for your contributions. |
I have added support for preserving npm in nvh if any readers would like to give it a try. (It was made possible by switching to rsync for the install and so can't be brought back to n.) |
Sometimes I need a different version of npm than the one installed with a version. Every time I switch node versions with n it wipes out my global node modules since it is a fresh copy from that installed version. This change backs up the global node modules so that the next time you switch to a previous version you were using the global node modules you installed will still be there.
run
./run_tests.sh
to demonstrate that this change fixes the problem.