Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Using Homebrew to manage Node.js and io.js installs on OSX

(Deprecated) Using Homebrew to manage Node.js and io.js installs on OSX

Having both Node.js and io.js installed with NVM was giving me a load of problems, mainly with npm. So I uninstalled NVM and manage Node.js and io.js with homebrew.
Heres how.

Install Node.js and io.js

$ brew install node
$ brew install iojs

Note the io.js install information:

This formula is keg-only.
iojs conflicts with node (which is currently more established)

So we have both Node.js and io.js installed, however iojs is only linked to the command iojs in our PATH.

So, we can unlink node: brew unlink node, and link iojs: brew link --force iojs this will link io.js to node and other commands.

Now when we need to use Node.js rather than io.js, we can just

$ brew unlink iojs && brew link node

To go back to io.js

$ brew unlink node && brew link --force iojs

And we can alias these (add to .bashrc / .zshrc)

alias usenode='brew unlink iojs && brew link node && echo Updating NPM && npm install -g npm@latest && echo Using Node.js'
alias useio='brew unlink node && brew link --force iojs && echo Updating NPM && npm install -g npm@latest && echo Using io.js'

Now we can $ usenode when we want to use Node.js, and $ useio when we want to use io.js

Twitter

byennen commented Feb 12, 2015

👍 thanks!

Interesting solution.

bcomnes commented Feb 12, 2015

Don't forget to patch npm's dependencies so it can try to build native add-ons.

A tap with these modifications lives here: https://github.com/aredridel/homebrew-iojs

Wo, it's kinda hacky - how about simply using https://github.com/creationix/nvm?

He mentioned above his reasons for doing this way; npm was causing issues when using both.

Yes, but would be better if we knew what kind of issues.

katrotz commented Sep 3, 2015

I had to add --overwrite option to brew link

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