When the “cask” option is used, the user has access to over 3800 Mac OS X GUI programs that can be installed and updated. With the “mas” option, the user can download and update programs from the Apple App Store. The Homebrew developer’s describe Homebrew very concisely: “Homebrew installs the stuff you need that Apple didn’t.”. Use Homebrew to install and update Node.js on Mac. The default method for installing Node.js is to download a pre-built installer for your platform.
If you’re looking for an easy guide to install Node.js and npm on OS X and macOS — this is it.
The whole process is reliant on Xcode being installed but good news is it doesn't need the full version of Xcode to be installed. However, for sake of simplicity I'm going to recommend downloading the full version of Xcode from the Mac App Store as this will install a number of powerful development tools for macOS while also installing the command line tools needed for Home Brew. Installing Homebrew on Mac OS X prior to El Capitan (that is Yosemite, Mavericks and others) used to be a breeze. But with a new change in OS X El Capitan called SIP - installing Homebrew has become a bit complicated. You need not worry, I have got you covered. Homebrew Logo - Mac. Download Homebrew for Mac & read reviews. Software package management.
Before we get started, are you listening to JS Party? If not, you should be! Maybe start with our episode all about best practices for Node developers. ✊
The default method for installing Node.js is to download a pre-built installer for your platform, install it and make sure it’s on your
$PATH
.However, 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 easily manage upgrades and updates — then this guide will help you get started.
Install Node.js and npm with Homebrew
How To Download Homebrew On Mac
First, install Homebrew.
Then run
brew update
to make sure Homebrew is up to date.As a safe measure you should run
brew doctor
to make sure your system is ready to brew. Run the command below and follow any recommendations from brew doctor.Next, add Homebrew’s location to your
$PATH
in your .bash_profile
or .zshrc
file.Next, install Node (npm will be installed with Node):
To test out your Node and npm install, try installing Grunt (you might be asked to run with sudo):
Homebrew Browser Zip File
If that worked then congratulations — you’ve installed Node.js, npm, and Grunt.
If not — retrace your steps or post a question to Stack Overflow.
Listen to related podcasts on The Changelog
Since you’re interested in Node.js, npm, and Homebrew — listen to some recent related podcasts we’ve done on those subjects.