Lazy: Take precedence over preinstalled node
SimenB opened this issue Β· comments
I installed yarn through brew instead of npm (as it's recommended that way), but since Yarn in brew depends on node, that gets installed as well, and using node
or npm
doesn't load nvm any more.
Hmmn, it would appear that the node
and npm
binaries are taking priority over the lazy loader functions.
Could you start a new session and let me know what which node
outputs. Also if you have any globally installed modules running which <module name>
would be helpful. Thanks :)
I just installed yarn through brew and I get:
$ which node
/usr/local/bin/node
So the brew node
binary does have a higher priority than the lazy loader node
function. I'm not quite sure why, I thought functions should have priority over PATH binaries. If I create a function in the session it does take priority:
$ which node
/usr/local/bin/node
$ node() { echo node }
$ which node
node () {
echo node
}
If I brew uninstall
yarn, node and npm, then npm install -g yarn
it works.
Since you can reproduce, I don't need to run which
? It's on another machine, so it's just a bit more work than no work at all π
Yep, I've done it haha
You can also disable NVM_LAZY_LOAD
and then zsh-nvm
and brew node can live together happily.
So you need to choose:
brew install yarn
andNVM_LAZY_LOAD=false
npm install -g yarn
andNVM_LAZY_LOAD=true
To clarify, the issue appears to be caused by brew node, I'm not quite sure how it's overriding the lazy load function. If I can figure out I may be able to get them to work together but I would suggest using one of the two options above :)
Found the conflict!
Working on a fix...
So it's kinda my fault? Cool! π
But yeah, adding node
and npm
to cmds
at creation time makes sense to me, at least
Haha no it's not your fault, you just seem to be really good at finding edge cases in my code π
Should have a fix shortly...
I've updated the fix from the other issue to specifically check for aliases rather than any binary/alias/function. That seems to have done the job.
@SimenB Let me know if this works for you :)
It works! Thanks.
I did figure out I could do brew install yarn --ignore-dependencies
. I then get env: node: No such file or directory
π Is it possible for me to append a custom command to the array you check? Say I did NVM_LOAD_CMDS=(yarn)
or something?
Great, thanks for raising the issue!
Sorry, I'm not too sure what you're asking for re the array. If you want to lazy load yarn I don't think that's gonna be possible because that's all handled with homebrew symlinks.
I don't want to lazy load yarn, but yarn depends on node, which is lazy loaded. So I want your same wrapper to include yarn (that is, load up nvm so Node is loaded)
Ahhhh, I see.
Yeah that would be possible although I'm kinda reluctant to do that. It's not a very common use case, the issue is occurring because you're using two different package managers to install node modules. The ideal solution would be to just use npm for everything, although yarn do make good arguments against it.
I think a better solution may be for me to manually check if yarn is installed and add that to the array. Other people will likely have this issue with yarn so it'll be nice if it works automatically. And it's unlikely to occur in any other scenarios so doesn't really warrant an extra option.
Yeah, that's fine as well π
I'll take a look at that tomorrow :)
You can track progress here: #16
No rush, thank you!