Skip to content

Instantly share code, notes, and snippets.

@jhohlfeld
Created June 12, 2015 08:10
Show Gist options
  • Save jhohlfeld/bc0ed726550192eb183d to your computer and use it in GitHub Desktop.
Save jhohlfeld/bc0ed726550192eb183d to your computer and use it in GitHub Desktop.
Run different node.js versions on a Mac using homebrew

I suppose you already installed homebrew nad have one current version of node installed.

Reference taken from https://gist.github.com/kugaevsky/68a7fa894551da9c310a

First, add an older formula of node:

$ cd /usr/local
$ git checkout b64d9b9c431642a7dd8d85c8de5a530f2c79d924 Library/Formula/node.rb
$ brew unlink node
$ brew install node
$ npm install -g npm@latest

Then use brew switch:

$ brew switch node 0.12.2_1
Cleaning /usr/local/Cellar/node/0.10.36
Cleaning /usr/local/Cellar/node/0.12.2_1
6 links created for /usr/local/Cellar/node/0.12.2_1
$ node -v
v0.12.2

and switch back again!

$ brew switch node 0.10.36
Cleaning /usr/local/Cellar/node/0.10.36
Cleaning /usr/local/Cellar/node/0.12.2_1
5 links created for /usr/local/Cellar/node/0.10.36
$ node -v
v0.10.36

Very powerful indeed.

@JordanTreDaniel
Copy link

I had to run brew link --overwrite node before this would work. Why?

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