-
Notifications
You must be signed in to change notification settings - Fork 68
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
Question: Make nvm use
usable for my own auto-switching?
#186
Conversation
Forgot to search pull requests in addition to issues 🤦 Found this one right now: #181 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the MR, I put some comments
👌. We either need a plumbing
Just curious, but why isn't your system Node always active? |
Yay! I’m excited 😄 🎉
I usually have the latest LTS installed via
|
How about we introduce a |
Edit: Oh wait, I’ll probably get errors when I (seldomly) go to, say, |
Yes, but you can redirect to /dev/null in this case since errors won't slow you down as _nvm_node_info does. |
Added a Please let me know if this should be all you need to implement automatic switching. |
I added this to function __nvm_auto --on-variable PWD
nvm use --silent 2>/dev/null
end
__nvm_auto And created
It seems to work perfectly so far!* 🎉 Thank you! |
9ms should do it. One could even get a bit fancier and put |
super fast and reliable so far! thx |
Question: we |
a local .nvmrc/.node-version file should always win IMO. That’s how my current setup works. In other words, I want no difference between |
What happens when you move to a directory without a .nvmrc (after you've auto-switched versions)? Should you auto-switch to the previous one? Assume such a directory is not a subdirectory of the one that had the .nvmrc file. |
Then I would like the default version. I’ve created |
Thank you, that makes sense and it's easy to do in userland too. |
- install nvm.fish (does not use original NVM, does not require bass) - add function to auto-switch node versions on directory change: jorgebucaran/nvm.fish#186 (comment) - add ~/.node-version file set to system, which is essentially used as a fallback if a version is not stated (otherwise it will stay on the last version specified)
- install nvm.fish (does not use original NVM, does not require bass) - add function to auto-switch node versions on directory change: jorgebucaran/nvm.fish#186 (comment) - add ~/.node-version file set to system, which is essentially used as a fallback if a version is not stated (otherwise it will stay on the last version specified)
- install nvm.fish (does not use original NVM, does not require bass) - add function to auto-switch node versions on directory change: jorgebucaran/nvm.fish#186 (comment) - add ~/.node-version file set to system, which is essentially used as a fallback if a version is not stated (otherwise it will stay on the last version specified)
Hi!
First, thanks for nvm.fish! It’s so fast and easy to use.
Note: I made this as a PR rather than as an issue because it’s easier to show some things using code. I don’t expect this to be merged in its current (ugly, incomplete) form!
I read #132 about the – now closed – suggestion about automatic version switching.
I get that it can be problematic. But I feel that for me, it can be more worth having automatic switching than perfection. So I started playing around with doing automatic switching myself:
However, there are a few problems with
nvm use
(with no arguments):node
call?) The slowness comes from_nvm_node_info
which invokesnode --eval
which isn’t the fastest./dev/null
though. I don’t need any prints, because my prompt shows the version. However, as mentioned in the above point, the prints are slow and/dev/null
does not help with performance..nvmrc
or.node-version
is found. I want it to switch to the default version in that case – which issystem
for me.I threw together some quick and bad modifications to
nvm.fish
to try things out. It looks promising!nvm use
now takes 8-12 ms to run, which feels acceptable to me on everycd
.system
if no.nvmrc
or.node-version
is found. (It should honor the default though, haven’t looked into that yet).What do you think? Would you be interested in having an
nvm use
optimized for this use case?Alternatively, any tips on how to use
nvm
effectively? Currently, I “fight” a lot with forgetting to switch version all the time. How do you do it? Would you recommend some other tool if this isn’t ”the nvm.fish philosophy”? (I’ve tried nodenv in the past, which has automatic switching, but it was so clunky to use.)