ZL
About Articles Contact
Published on Nov 20, 2019
Filed under:
#workstation,
#tools

Understanding Homebrew

Homebrew is a package manager for Mac OS. It lets you download binaries, packages, and applications with a single command.

In this article, I want to explain how to use Homebrew.

Installing Homebrew

You can install Homebrew with this command:

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

Updating Homebrew

To update homebrew, you use brew update. This updates Homebrew to its latest version. (You always want Homebrew to be at the latest version before downloading anything).

Terminal window
# updates Homebrew
brew update

Installing a package

Each package is called a formula. To install a formula, you use the install command.

Terminal window
brew install <formula>

For example, to install Node with Homebrew, you use this:

Terminal window
brew install node

If you’re feeling bored, here’s a list of everything you can install with Homebrew. You can also find a list of formulae I use in my Dotfiles repository. (Unsure what dotfiles are? Read this).

Upgrade a package

To upgrade one package, you use this:

Terminal window
# Upgrades one package to the latest version
brew upgrade <formula>

To upgrade all packages, you use brew upgrade without specifying any formulas.

Terminal window
# Upgrades all packages to their latest version
brew upgrade

Downgrade a package

Let’s say you have the latest version of Node installed. You want to downgrade to a previous version.

First, you need to use brew search to find the package.

Terminal window
brew search node

You want to find the possible versions to download from the results. In this example, we can install node v8 or v10.

Brew search.

Install the version you want to use. In this case, lets install Node 10.

Terminal window
brew install node@10

Next, we need to unlink our current node version.

Terminal window
# Unlinking node
brew unlink node

Then, we need to link the version we installed. In this case, it’s Node@10. To link a formula, you use the link command.

Terminal window
# Linking node
brew link node@10
Linking Node 10.

Sometimes, (like in this case), you need to use --force to link the formula.

Terminal window
brew link node@10 --force
Linking Node 10 with --force.

Now if you run node -v, you should see that Node v10 is installed.

Terminal window
node -v
Checking for Node version.

Notice its Node is now v10.16.3. Unfortunately, with Homebrew, we don’t get to use Semantic Versioning with Homebrew, so you can’t install specific versions. You can only perform major version upgrade/downgrades.

(But this is enough 99% of the time).

To change back to the latest node version, you repeat the unlink and link steps:

Terminal window
brew unlink node@10
brew link node
Switches back from Node 10 to Node 12.

Here’s the funny thing about Node + Homebrew.

When you run brew `link node, Homebrew doesn’t install npm for you. So if you want to install any Node version, make sure you run install or reinstall instead.

Terminal window
brew reinstall node

I really shouldn’t have used Node as an example 🤦‍♂️… But I still decided to use it because nobody talked about the npm problem I mentioned above.

¯_(ツ)_/¯

Deleting a package

To remove a package, you use the uninstall command.

Terminal window
brew uninstall <formula>

Brew cleanup

Once in a while, you might want to run brew cleanup to remove state and outdated downloads from your computer. (Free up space! 😎).

Terminal window
brew cleanup

Brew tap

Homebrew manages a list of formulae in a place called homebrew/core. When you install files, you install from this list.

“Core” here means folks at Homebrew maintain the formulae list.

Other people can let you install their stuff with Homebrew as well. To do this, they need to create a formulae list. Then, they have to publish this list.

brew tap lets you add a third-party formulae list into Homebrew. Once you added the formulae list, you can use brew install to install the formula.

For example, to install MongoDB with Homebrew, you need to tap into mongodb/brew.

Terminal window
# Required to install MongoDB with Homebrew
brew tap mongodb/brew

Then, you install MongoDB like this:

Terminal window
# Installs MongoDB
brew install mongodb-community

Brew Cask

Homebrew contains another formulae list called homebrew/cask. This list lets you install GUI applications like Google Chrome, Safari, Atom, and others.

To install a cask, you use the brew cask install command.

Terminal window
# Installs Google Chrome
brew cask install google-chrome

That’s it!

Previous Designing Learn JavaScript's course portal (Part 3) Next Element.focus vs aria-activedescendant

Join My Newsletter

I share what I’m learning on this newsletter: code, building businesses, and living well.

Sometimes I write about technical deep-dives, product updates, musings on how to live, and sometimes my struggles and how I’m breaking through.

Regardless of the type of content, I do my best to send you an update every week.

If you’re into making things and growing as a person, you’ll probably feel at home here.

“

Zell’s writing is very accessible to newcomers because he shares his learning experience. He covers current topics and helps all readers level up their web development skills. Must subscribe.

Chen Hui Jing
Chen Hui Jing — Web Developer
The Footer

General

Home About Contact Testimonials Tools I Use

Projects

Magical Dev School Splendid Labz

Socials

Youtube Instagram Tiktok Github Bluesky X

Follow Along

Email RSS
© 2013 - 2025 Zell Liew / All rights reserved / Terms