Skip to content

Instantly share code, notes, and snippets.

@tomysmile
Last active January 10, 2017 05:29
Show Gist options
  • Save tomysmile/df6755278f875d97b7e4 to your computer and use it in GitHub Desktop.
Save tomysmile/df6755278f875d97b7e4 to your computer and use it in GitHub Desktop.
Node: Install NVM
brew update
brew install nvm
mkdir ~/.nvm
nano ~/.profile

In your .bash_profile file (you may be using an other file, according to your shell), add the following :

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

Back to your shell, activate nvm and check it (if you have other shells opened and you want to keep them, do the same) :

source ~/.bash_profile
echo $NVM_DIR

Now, you can install node :

nvm install 0.12

From now on, you’re using the v0.12.x of node on this shell, you can install your global dependencies such as grunt-cli (they will be tied up to this version of node).

You may want to install other versions, just do :

nvm install 0.10
nvm install iojs
...

You’ll have to npm install -g your global dependencies for each version.

Switch of node version with nvm use 0.10 (more infos here).

To have a node activated by default (not to have to nvm use on each new shell), run this (stable being the id of the version):

nvm alias default stable

Now, you can run multiple versions of node on your computer.

Installing NVM

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
$ echo source "~/.profile" >> ${HOME}/.bash_profile
$ source ~/.profile

$ nvm install 0.12

to use that specific node, just type:

$ nvm use 0.12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment