Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nvm keeps "forgetting" node in new terminal session

Upon using a new terminal session in OS X, nvm forgets the node version and defaults to nothing:

$ 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.

My .profile for the brew version:

#nvm export NVM_DIR=~/.nvm source $(brew --prefix nvm)/nvm.sh 

And for the install.sh script:

$ curl https://raw.githubusercontent.com/creationix/nvm/v0.10.0/install.sh | bash

#nvm export NVM_DIR="/Users/farhad/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm 

Any clue to what I'm doing wrong?

like image 919
frhd Avatar asked Jul 05 '14 10:07

frhd


People also ask

How do I permanently change Node version of NVM?

Just type nvm alias default v10. 16.3 in your terminal and then type nvm use default . This command will make v10. 16.3 available in any shell you open — you just have to restart your terminal to make sure it works.

Does NVM switch npm?

nvm doesn't handle npm. So if you want to install node 0.4. x (which many packages still depend on) and use NPM, you can still use npm 1.0.


2 Answers

Try nvm alias default. For example:

$ nvm alias default 0.12.7

This sets the default node version in your shell. Then verify that the change persists by closing the shell window, opening a new one, then: node --version

like image 66
dylants Avatar answered Sep 21 '22 10:09

dylants


Alias to node itself to avoid updating the default alias along with node version updates later on.

nvm alias default node 
like image 44
Tarun Avatar answered Sep 20 '22 10:09

Tarun