1
$ nvm ls:

     .nvm
 v0.11.12
 v0.11.13

I have to keep hitting nvm use v.0.11.13 in every session:

     .nvm
 v0.11.12

-> v0.11.13 I've tried both the brew install, as well as the official installation script.

Vivek Molkar
  • 3,910
  • 1
  • 34
  • 46
sekhar kumar
  • 13
  • 1
  • 5

2 Answers2

5

use this in the terminal.

$ nvm alias default v0.11.13

for more help go to https://github.com/creationix/nvm or write nvm help in terminal.

Atishay Jain
  • 1,425
  • 12
  • 22
2

Try putting a .nvmrc file at the root of your project. It shall contain:

v0.11.13

Then, you could add this little snippet at the end of your ~/.bashrc (or whatever bash you're using):

# Use node version (nvm use)
autoload -U add-zsh-hook
load-nvmrc() {
  if [[ -f .nvmrc && -r .nvmrc ]]; then
    nvm use
  elif [[ $(nvm version) != $(nvm version default)  ]]; then
    echo "Reverting to nvm default version"
    nvm use default
  fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc

This should properly set the node version as soon as you enter a directory containing a proper .nvmrc file.

SinDeus
  • 516
  • 1
  • 6
  • 21