node.js is not - nvm keeps “forgetting” node in new terminal session

5 Answers

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

nvm alias default node
compatible with the

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

$ nvm ls:


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

->   v0.11.13

I've tried both the brew install, as well as the official installation script.

My .profile for the brew version:

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

And for the script:

$ curl | bash

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

Any clue to what I'm doing wrong?

nvm does its job by changing the PATH variable, so you need to make sure you aren't somehow changing your PATH to something else after sourcing the script.

In my case, was being called in .bashrc but then the PATH variable was getting updated in .bash_profile which caused my session to find the system node before the nvm node.

The top rated solutions didn't seem to work for me. My solution is below:

  1. Uninstall nvm completely using homebrew:brew uninstall nvm
  2. Reinstall brew install nvm
  3. In Terminal, follow the steps below(these are also listed when installing nvm via homebrew):

    mkdir ~/.nvm cp $(brew --prefix nvm)/nvm-exec ~/.nvm/ export NVM_DIR=~/.nvm source $(brew --prefix nvm)/

The steps outlined above will add NVM's working directory to your $HOME path, copy nvm-exec to NVM's working directory and add to $HOME/.bashrc, $HOME/.zshrc, or your shell's equivalent configuration file.(again taken from whats listed on an NVM install using homebrew)

run this after you installed any version,

n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local

This command is copying whatever version of node you have active via nvm into the /usr/local/ directory and setting the permissions so that all users can access them.

If you have tried everything still no luck you can try this :_

1 -> Uninstall NVM

rm -rf ~/.nvm

2 -> Remove npm dependencies by following this

3 -> Install NVM

curl -o- | bash

4 -> Set ~/.bash_profile configuration

Run sudo nano ~/.bash_profile

Copy and paste following this

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

5 -> CONTROL + X save the changes

6 -> Run . ~/.bash_profile

7 -> Now you should have nvm installed on your machine, to install node run nvm install v7.8.0 this will be default node version or you can install any version of node