What Is Homebrew?

Homebrew is a package manager for macOS and Linux that makes it easy to install, update, and manage developer tools and command-line software.

Learn software development

Instead of manually downloading software, finding installers, configuring paths, and managing updates, you can often install a package with a single command.

For example:

brew install node

That command downloads and installs Node.js along with what it needs.

1. Installing Homebrew

On macOS, Homebrew is commonly installed from the Terminal using its official installation command.

Homebrew official website

After installation, verify that it works:

brew --version

You should see the installed Homebrew version.

You can also check where Homebrew is installed:

which brew

On Apple Silicon Macs, Homebrew is typically installed under:

/opt/homebrew

On Intel Macs, it is commonly under:

/usr/local

2. Updating Homebrew

Before installing software, it is useful to update Homebrew’s package information:

brew update

This updates Homebrew’s knowledge of available packages and their latest versions.

You can check whether anything needs updating with:

brew outdated

3. Installing Software

The basic syntax is:

brew install package-name

For example:

brew install node

Other common development tools include:

brew install git
brew install python
brew install wget
brew install curl

You can install multiple packages in one command:

brew install git node python

4. Searching for Packages

If you don’t remember the exact package name, search for it:

brew search python

You can then choose the appropriate package from the results.

To get information about a package:

brew info node

This can show its version, installation location, dependencies, and other useful information.

5. Listing Installed Packages

To see software installed through Homebrew:

brew list

For a more detailed list of installed formulae:

brew list --formula

You can also inspect installed applications known as casks:

brew list --cask

6. Installing GUI Applications

Homebrew can also install many macOS applications through Homebrew Cask.

For example:

brew install --cask visual-studio-code

Other examples include:

brew install --cask google-chrome
brew install --cask firefox
brew install --cask iterm2

Casks are particularly useful when you want to manage desktop applications from the command line.

7. Updating Installed Software

To upgrade outdated Homebrew packages:

brew upgrade

To upgrade a specific package:

brew upgrade node

For cask applications:

brew upgrade --cask

You can also perform:

brew update
brew upgrade

to update Homebrew’s package information and then upgrade installed packages.

8. Uninstalling Software

If you no longer need a package:

brew uninstall node

For a cask:

brew uninstall --cask visual-studio-code

You can verify that it has been removed with:

brew list

9. Cleaning Up

Homebrew can accumulate older versions and cached downloads.

Run:

brew cleanup

To see what would be removed without actually deleting anything:

brew cleanup --dry-run

This is useful for recovering disk space.

10. Managing Services

Homebrew can manage background services such as databases and development servers.

For example, after installing MySQL:

brew install mysql

You can start it as a background service:

brew services start mysql

Check running Homebrew services:

brew services list

Stop the service:

brew services stop mysql

This is especially useful when setting up local development environments.

11. Installing a Specific Version

Sometimes a project requires a particular version of a tool.

Homebrew provides versioned formulae when available. For example:

brew search node

may reveal available versioned packages.

You can then install the required version if Homebrew provides it.

However, Homebrew is generally designed around current package versions, so developers who need to switch between many versions often use specialized version managers such as nvmpyenv, or similar tools.

12. Finding Where a Package Is Installed

Use:

brew --prefix

To find the installation directory of a particular package:

brew --prefix node

You can also inspect package information:

brew info node

This is helpful when troubleshooting PATH issues or locating configuration files.

13. Checking Homebrew’s Health

Homebrew provides a diagnostic command:

brew doctor

It checks your Homebrew environment for potential problems.

If it reports warnings, read them carefully before making changes. Some warnings are informational rather than critical.

14. Useful Homebrew Commands

CommandPurpose
brew --versionShow Homebrew version
brew updateUpdate Homebrew metadata
brew upgradeUpgrade installed packages
brew search nameSearch for packages
brew info nameShow package information
brew install nameInstall a package
brew uninstall nameRemove a package
brew listList installed packages
brew outdatedShow outdated packages
brew cleanupRemove old cached versions
brew doctorDiagnose potential problems
brew services listList Homebrew services
brew services start nameStart a service
brew services stop nameStop a service

Homebrew for Developers

Homebrew becomes particularly useful when setting up a development machine.

A new developer can quickly install tools such as:

brew install git
brew install node
brew install python
brew install php
brew install mysql

Instead of searching for each installer individually, Homebrew provides a consistent command-line workflow.

You can think of the basic workflow as:

SEARCH
   ↓
INSTALL
   ↓
USE
   ↓
UPDATE
   ↓
UPGRADE
   ↓
CLEAN UP

A Simple Example

Suppose you want to build a Node.js application on a new Mac.

You could install Node.js:

brew install node

Verify it:

node --version

Verify npm:

npm --version

Then create a project:

mkdir my-app
cd my-app
npm init -y

Homebrew handled the system-level installation, while npm handles Node.js packages inside your project.

Important Distinction

Homebrew and npm are not the same thing.

Homebrew manages system-level software:

brew install node

npm manages JavaScript packages:

npm install express

So a typical development setup might use both:

Homebrew
   ↓
Node.js
   ↓
npm
   ↓
JavaScript packages
   ↓
Your application

Homebrew is therefore more than an installer. It provides a convenient way to build and maintain a reproducible command-line development environment on macOS and Linux.

Recent Posts

10 Ways to Loop Through a JavaScript Array

JavaScript gives you several ways to iterate over an array. Some are better for simple…

2 days ago

Build a Node JS Web Server

A web server is the software responsible for receiving requests from clients, processing those requests,…

4 days ago

Shell Prompt Tutorial

A shell prompt is the text displayed by a command-line shell to show that it is ready…

1 week ago

The SOC Analyst

A SOC Analyst (Security Operations Center Analyst) is one of the frontline defenders of an organization’s cybersecurity…

3 weeks ago

Building an Offline-Friendly Image Upload System

Most image upload systems assume one thing: the user has a stable internet connection. That assumption…

4 weeks ago

JavaScript Background Sync API

Imagine a user submits a form while their internet connection suddenly disappears. Normally, the request…

4 weeks ago