Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

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 Using Node.js'
alias useio='brew unlink node && brew link --force iojs && echo Using io.js'

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

Discuss on HN | Twitter

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