Install Node.js and npm using Homebrew on OS X

Homebrew, the missing package manager for OS X. The standard Node.js and npm install method for OS X is to download a pre-built installer for your platform, install it, and make sure it’s on your $PATH. But since you have homebrew, you have a better way of installing it and its as easy as pie!

Install Node.js and npm with Homebrew

First you need to install homebrew if you do not have it.

ruby -e "$(curl -fsSL"

Thats going to chug away for a while. Then, brew update to ensure your Homebrew is up to date.

brew update

All homebrew users know that they should make it habitual to run brew doctor. So lets run it right now, even though if you just installed homebrew you don't need it yet.,

brew doctor

Make sure that homebrew is in your path. I do this by putting the following in my /.bash_profile

export PATH="/usr/local/bin:$PATH"

And finally we install Node (npm will be installed with node):

brew install node

We test out our Node and npm install, try installing Grunt.

npm install -g grunt-cli

If that worked, congrats, you’re good to go with Node.js, npm, and Grunt. If not, retrace your steps.