I am typing this command which should make the node version default for all sessions:
nvm alias default stable // v0.12.0
And when i open another tab and type:
node -v i get v1.0.2
Do you have a ~/.nvmrc file created?
No, what i need to do?
What's your nvm ls output?
v0.10.34
v0.10.35
v0.12.0
-> system
So your system version is io.js v1.0.2?
What OS and shell are you on?
(Thanks btw, I'll get to this ASAP)
yosemite zsh
Hi @NetanelBasal ,
did you try to do it like this?
$ nvm use 0.12.0
$ nvm alias default 0.12.0
Yes, still does not work.
I can't reproduce this on yosemite with zsh.
What's your nvm alias output? I'm wondering if perhaps nvm alias default stable isn't actually able to create the alias file, perhaps due to permissions issues.
default -> 0.10.35 (-> v0.10.35)
stable -> 0.12 (-> v0.12.0) (default)
ok so what's your nvm alias output after running nvm alias default stable?
☁ ~ nvm alias
default -> 0.10.35 (-> v0.10.35)
stable -> 0.12 (-> v0.12.0) (default)
☁ ~ nvm alias default stable
stable
default -> stable (-> v0.12.0)
☁ ~ nvm alias
default -> stable (-> v0.12.0)
stable -> 0.12 (-> v0.12.0) (default)
And now that that's done, what's the full nvm ls output in a new shell?
When i open new tab:
v0.10.34
v0.10.35
v0.12.0
-> system
default -> v0.10.35
stable -> 0.12 (-> v0.12.0) (default)
Wow, ok thanks for bearing with me. Assuming your $NVM_DIR is ~/.nvm, what are the contents of the ~/.nvm/alias dir, and of the file ~/.nvm/alias/default?
I have one file there called default and inside him i see v0.10.35 (cause i change this to be default instead 0.12)
So this is the part that I'm confused about: nvm alias default stable should make the "default" file contain only the string "stable" - and running nvm alias or nvm ls afterwards, and seeing that default is in fact stable means it worked.
Is there a possibility that you have an nvm alias default 0.10.35 line somewhere in your .zshrc, such that simply opening a new terminal resets the default?
No the only thing that related to nvm is this line in zsh file:
source ~/.nvm/nvm.sh
… and your .zshrc doesn't source another file that might have a line like that?
No, i find "nvm" in my text editor and this is the only line with this word.
I dont understand why its stuck on _system_ when i do nvm ls
@NetanelBasal I assume that nvm use works fine? ie nvm use stable?
Yes, because it does not work i created an alias in zsh that run nvm use default
OK, so just clarifying :-) the only thing not working for you right now is that when you set up a default, and open a new shell, the default isn't used?
Yes, when i write nvm alias default stable and then open another tab, in the node -v i get the system default _v1.0.2_
not sure if this will help, but I also have this line in the .zshrc:
[ -s $HOME/.nvm/nvm.sh ] && . $HOME/.nvm/nvm.sh
Not working, you are using zshell and os yosemite and its work on your computer?
@NetanelBasal are you by chance using oh-my-zsh, or are you using the stock zsh that comes with OS X?
oh-my-zsh
ah HA, i wish you'd started with that :-) zsh people hate omz because it sets up so many complex options by default. That definitely changes things.
So you have way to do this?
Use stock zsh and it will work fine - that's what nvm is tested on. In order to fix nvm for oh-my-zsh, I either have to figure out exactly which zsh option is causing the problem, or, figure out a general purpose solution that can safely disable all zsh flags solely for nvm command execution.
How i change to stock zsh?
I am using oh-my-zsh with out-of-the-box settings and nvm is working fine.
I'm on Yosemite
@NetanelBasal Can you gist the entire contents of your zshrc file (with anything sensitive edited out)? You may be setting some additional options that I could work with.
This is my zshrc file
@NetanelBasal This line is the problem https://gist.github.com/NetanelBasal/f42b3f362cd50f89d541#file-gistfile1-txt-L55
You're overwriting the PATH entirely with something new, which a) is a bad idea, and b) breaks nvm's default behavior. Note how on line 60 https://gist.github.com/NetanelBasal/f42b3f362cd50f89d541#file-gistfile1-txt-L60 the existing PATH is preserved? Apply that technique to line 55.
You are right i am sorry for this i did not notice, thanks a lot man.
Hey just a heads up these posts helped me resolve my issue as well. Thanks a bunch!
could you provide the links to the gists again? in these links nothing seems to be available.
i think i have the same error...
@lehnerchristian essentially there was a line in their profile file which did export PATH=blah without doing export PATH=$PATH:blah.
I'm not sure, but I think I had to add export NVM_DIR=~/.nvm
Anyway now it works!
Thanks for your fast answer!
Most helpful comment
@NetanelBasal This line is the problem https://gist.github.com/NetanelBasal/f42b3f362cd50f89d541#file-gistfile1-txt-L55
You're overwriting the PATH entirely with something new, which a) is a bad idea, and b) breaks
nvm's default behavior. Note how on line 60 https://gist.github.com/NetanelBasal/f42b3f362cd50f89d541#file-gistfile1-txt-L60 the existing PATH is preserved? Apply that technique to line 55.