Reputation: 3199
I used nvm (node version manager) to upgrade node form v0.4 to v0.6.9 I used the following commands:
node -v -> v0.4.x
cd ~
git clone git://github.com/creationix/nvm.git ~/.nvm
. ~/.nvm/nvm.sh
nvm install v0.6.9
//wait a while
node -v -> v0.6.9
The problem is that each time I reboot my mac, node -v prints out v0.4. So I have to redo the procedure. I also have to run rm -rf .nvm
before git clone. Can you please tell me why that happens and how can I fix it? Thanks.
Upvotes: 4
Views: 1176
Reputation: 20526
The simplest way I've found is:
nvm alias default v8.4.0
(insert your version number of course)
Upvotes: 0
Reputation: 11354
Run this command to see what's currently running:
node -v ; which node ; echo $PATH ; npm root -g
Now, install the new version of node you want:
nvm install x.x.x
Now, set this new version as the default version:
nvm alias default x.x.x
This won't change anything in your current session, so create new session and then try this again:
node -v ; which node ; echo $PATH ; npm root -g
It should now show that the new version you've installed is now being used.
Upvotes: 0
Reputation: 30420
Well the thing is that nvm installs node into a directory that is not in the normal executable path(/usr/bin/), so it's path have have to be put in PATH environmental variable every time you open a console or terminal which is what . ~/.nvm/nvm.sh
does. So you have to do it every time you open your console or terminal. Technically you can also use node from the path like this:
/home/alfred/.nvm/v0.6.7/bin/node -v
And if you want to set your path to node automatically you should just put that line into . ~/.nvm/nvm.sh
into your ~/.bashrc
or ~/.profile
files. And you will have your node after each terminal start up.
Upvotes: 1
Reputation: 12543
The info I think you're missing is that nvm lets you manage multiple versions simultaneously. It does this by playing magic with your environment and paths.
After a reboot, I suspect you need only run these lines:
. ~/.nvm/nvm.sh
nvm use v0.6.9
That should cause you to re-enter the "magic" nvm environment which you previously installed v0.6.9 in.
Upvotes: 4