1

My nvm keep forgetting about the node environment ever since I upgraded to Yosemite(A few months ago)/Capitan EL(I upgraded this week) even though I did

nvm alias default 0.12

Hilariously, it told me after I hit enter

default -> 0.12 (-> v0.12.8)

But when I opened a new terminal it said node: command is not found!!

There are a couple of solutions I tried so far:

  • I have tried using brew uninstall nvm & brew install nvm
  • as well as the installing script, since brew complaint it doesn't work with the pre-released OS(which is actually GA right now)
  • I double checked bash_profile do have the following lines

    export NVM_DIR=~/.nvm

    source $NVM_DIR/nvm.sh

Unfortunately, none of them works. Have anyone run into a similar issue before?

Thanks!

yeelan
  • 1,387
  • 2
  • 16
  • 22
  • Just checking, does `nvm use 0.12` actually load the correct nvm for you? Using the `alias` did not work for me as well, but what I did was merely add `nvm use > /dev/null` in my bash_profile for it to load. – CKD Dec 22 '15 at 21:18
  • if you run `NVM_DIR=$HOME/.nvm` and `$NVM_DIR/nvm.sh` from command line, does it still throw the error? Would be good if you had the error message shown. – CKD Dec 22 '15 at 21:33
  • Also try http://stackoverflow.com/questions/24585261/nvm-keeps-forgetting-node-in-new-terminal-session?rq=1 in case you have not read this thread. – CKD Dec 22 '15 at 21:35
  • Thanks @CKD. I tried to run the command manually but it still give me the error. I ended up doing exactly the same as you do. I guess it should be a temporarily solution and need really look into why this is happening any way. – yeelan Dec 23 '15 at 04:50
  • Did you install using brew or with the `curl` command? The recommended solution on the nvm is to follow these https://github.com/creationix/nvm#install-script. – CKD Dec 23 '15 at 05:00
  • Also can you edit your question to have the exact error message thrown when you run `NVM_DIR=$HOME/.nvm` and `$NVM_DIR/nvm.sh` – CKD Dec 23 '15 at 05:01

3 Answers3

1

This is merely a temporary solution, however, it works.

  1. Add nvm use stable in ~/.bash_profile(or whatever version you want to use to replace stable)

  2. Save the file

  3. Do source ~/.bash_profile after this or simply open a new terminal tab.

yeelan
  • 1,387
  • 2
  • 16
  • 22
0

This worked for me on El Capitan

brew uninstall nvm
brew install nvm
mkdir ~/.nvm
export NVM_DIR="$HOME/.nvm"
 . "$(brew --prefix nvm)/nvm.sh"

It said that .nvm folder already existed but I ignored that.

Papershine
  • 4,995
  • 2
  • 24
  • 48
0

I just used this command in MacOS el capitan

$> nvm alias default v6.4.0

It worked as expected. Please notice the small v before the version number.

And finally, just if it helps, I used this command to install nvm as is described in the nvm project readme.

$> curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
mario.ecc
  • 150
  • 1
  • 8