I am trying to make all new terminal sessions uses the stable version of node that I have installed.
Here is output of 'nvm ls'
v0.12.7
-> v4.2.6
system
default -> stable (-> v4.2.6)
node -> stable (-> v4.2.6) (default)
stable -> 4.2 (-> v4.2.6) (default)
iojs -> N/A (default
I've also added this to my .bashrc file
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
nvm use stable
When I open a new terminal I can see the output Now using node v4.2.6 (npm v2.14.12)
But when I run node -v I get v0.12.7 I then have to run nvm use stable again and then it works as expected.
Any suggestions would be welcome, perhaps I've missed a step or misconfigured something?
This is by design. nvm alias default node will make it stick.
Make sure you're also using the latest version of nvm itself, just in case :-)
Hi
I just updated to version 0.31.0 I was on 0.29.0 before.
I tried 'nvm alias default node' via shell and also in bashrc but neither has made a difference.
Noticed when I run 'nvm current' it prints out system when opening a new window.
Thank you
@gunnx can you provide nvm debug and nvm ls output?
Output of 'nvm ls' on a new terminal window:
v0.12.7
v4.2.6
-> system
default -> node (-> v4.2.6)
node -> stable (-> v4.2.6) (default)
stable -> 4.2 (-> v4.2.6) (default)
iojs -> N/A (default)
Output of nvm debug on new terminal window
nvm --version: v0.31.0
$SHELL: /bin/bash
$HOME: /Users/user1
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: system
which node: /usr/local/bin/node
which iojs:
which npm: /usr/local/bin/npm
npm config get prefix: /usr/local
npm root -g: /usr/local/lib/node_modules
It seems like you probably have something in your bash profile files that's setting the $PATH, after nvm is sourced. Can you gist your .bashrc and/or .bash_profile, with any sensitive parts edited out?
I've merged the files into one here:
https://gist.github.com/gunnx/ee7b86b6c44aaebb3c459453670957bd
@gunnx yup, that's the problem. in bash_profile, you're sourcing bashrc first - and then after that, https://gist.github.com/gunnx/ee7b86b6c44aaebb3c459453670957bd#file-bash-extract-txt-L9-L10 take over the PATH and take precedence. I'd recommend moving https://gist.github.com/gunnx/ee7b86b6c44aaebb3c459453670957bd#file-bash-extract-txt-L3 to the bottom of bash_profile to fix it.
thanks @ljharb that did the trick, much appreciated!
I you have this line in side ~/.zshrc file just comment that out.
export PATH="/usr/local/opt/node@8/bin:$PATH"
Most helpful comment
@gunnx yup, that's the problem. in
bash_profile, you're sourcingbashrcfirst - and then after that, https://gist.github.com/gunnx/ee7b86b6c44aaebb3c459453670957bd#file-bash-extract-txt-L9-L10 take over the PATH and take precedence. I'd recommend moving https://gist.github.com/gunnx/ee7b86b6c44aaebb3c459453670957bd#file-bash-extract-txt-L3 to the bottom ofbash_profileto fix it.