If you’re looking for an easy to follow guide on installing Node.js and npm on OS X, the default method is to download a pre-built installer for your platform, install it, and make sure it’s on your
But, if you’re a Homebrew fan like me and prefer to install all of your packages with it — ensuring your packages are installed using the same commands and directories and allowing Homebrew to manage updates – this guide will help you get started.
Install Node.js and npm with Homebrew
First, install Homebrew.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update to ensure your Homebrew is up to date.
As a safe measure, run
brew doctor to make sure your system is ready to brew. Follow any recommendations from brew doctor.
Next, add the Homebrew location to your
$PATH and source your bash or zsh profile file after adding/saving this:
Next, install Node (npm will be installed with node):
brew install node
To test out your Node and npm install, try installing Grunt (you might be asked to run with sudo):
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, or say hi on Twitter.
Have comments? Send a tweet to @TheChangelog on Twitter.
Subscribe to The Changelog Weekly – our weekly email covering everything that hits our open source radar.