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!
First you need to install homebrew if you do not have it.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Thats going to chug away for a while. Then, brew update to ensure your Homebrew is up to date.
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.,
Make sure that homebrew is in your path. I do this by putting the following in my /.bash_profile
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.