Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have placed this at the bottom of my ~/.bashrc:

# NVM
. ~/nvm/nvm.sh
nvm ls
nvm use 0.8
nvm ls

This is the output when I load a terminal:

Last login: Mon Apr 29 16:28:17 on ttys010
    v0.4.7     v0.6.14      v0.8.4      v0.8.6     v0.8.12
current:  v0.8.12
default -> 0.8 (-> v0.8.12)
Now using node v0.8.12
    v0.4.7     v0.6.14      v0.8.4      v0.8.6     v0.8.12
current:  v0.8.12
default -> 0.8 (-> v0.8.12)
usr$ which node
/Users/Vaughan/nvm/v0.8.12/bin/node

And when I run source ~/.bashrc:

usr$ source ~/.bashrc
    v0.4.7     v0.6.14      v0.8.4      v0.8.6     v0.8.12
current:  v0.6.1
default -> 0.8 (-> v0.8.12)
Now using node v0.8.12
    v0.4.7     v0.6.14      v0.8.4      v0.8.6     v0.8.12
current:  v0.6.1
default -> 0.8 (-> v0.8.12)
usr$ which node
/usr/local/bin/node

As you can see, the version of node is incorrect. It no longer references the nvm version.

What on earth could be going wrong?

share|improve this question
    
Check the order in which the $PATH is evaluated – dawud Apr 29 '13 at 6:39
    
In OS X, .bashrc isn't loaded from anywhere, really. Put your code in ~/.bash_profile instead. – slhck Apr 29 '13 at 6:43
    
I load ~/.bashrc from ~/.bash_profile like so: if [ -f ~/.bashrc ]; then source ~/.bashrc fi – vaughan Apr 29 '13 at 6:45
    
Okay, maybe I'm not understanding the question correctly, but wouldn't the answer be: don't run .bashrc again? It works when you load the terminal, right? Maybe nvm.sh doesn't like to be called twice. – slhck Apr 29 '13 at 6:47
    
I want it to run in each terminal. And there are times when I adjust env vars from ~/.bashrc. nvm.sh appears to not set the path when already activated. I think this is an issue to raise with nvm considering it is recommended to run it from ~/.bashrc. Thanks for your help though, got me thinking in the right direction. – vaughan Apr 29 '13 at 6:52

I removed these two lines from the top of ~/.bashrc and moved them to ~/.bash_profile.

export NODE_PATH="/usr/local/lib/node"
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/Users/Vaughan/bin:$PATH"

Now I can run source ~/.bashrc without disrupting Node or nvm.

The issue was that nvm does not reset the PATH when run.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .