Skip to Content
Frontlane Studio
All Snippets
Bash WP-CLI December 6, 2023

Install Node.js and npm using Homebrew on OS X and macOS

First, install Homebrew.

WP-CLI WordPress Bash

First, install Homebrew.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install Node.js and npm with Homebrew

Then run brew update to make sure Homebrew is up to date.

brew update

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.

brew doctor

Next, add Homebrew’s location to your $PATH in your .bash_profile or .zshrc file.

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

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