You typed a command in Terminal and got this:

zsh: command not found: somecommand

This means your Mac can't find the program you're trying to run. It's not broken. It's either not installed, or your Mac doesn't know where to look for it.

Here's how to fix it.

The Three Reasons This Happens

1. You Made a Typo

Sounds obvious, but check your spelling. Terminal is case-sensitive. Brew is not the same as brew. One extra space or missing letter will trigger this error.

Try the command again. Look closely.

2. The Program Isn't Installed

You might be trying to run something that doesn't exist on your Mac yet. Common examples:

  • brew - Homebrew isn't installed by default
  • python - Python 3 is python3 on newer Macs
  • node - Node.js requires a separate install
  • git - Works after installing Xcode Command Line Tools

To check if something is installed, use the which command:

which brew

If it returns nothing, that program isn't installed. If it returns a path like /opt/homebrew/bin/brew, it's installed but something else is wrong (see #3).

3. Your PATH Is Broken

This is the most common cause after installing new software.

Your Mac has a list of folders it searches when you type a command. This list is called the PATH. If a program is installed but its folder isn't in your PATH, you'll get "command not found."

Check your current PATH:

echo \$PATH

You'll see something like:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Those are the folders your Mac searches, separated by colons.

How to Fix a Broken PATH

If you just installed Homebrew, Node, Python, or another tool and it's not working, you probably need to add it to your PATH.

Quick Fix (Temporary)

Run this to reset your PATH to the default:

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

This works immediately but only lasts until you close Terminal.

Permanent Fix

You need to edit your shell configuration file. On modern Macs (Catalina and later), that's .zshrc in your home folder.

Open it:

nano ~/.zshrc

Add a line that includes the path to your program. For Homebrew on Apple Silicon Macs:

eval "\$(/opt/homebrew/bin/brew shellenv)"

For Homebrew on Intel Macs:

eval "\$(/usr/local/bin/brew shellenv)"

Save the file (Control+O, then Enter, then Control+X) and reload it:

source ~/.zshrc

Try your command again. It should work now.

Common Specific Fixes

"command not found: brew" Homebrew isn't in your PATH. See the permanent fix above, or reinstall Homebrew - the installer will give you the exact commands to run.

"command not found: python" On newer Macs, use python3 instead. Apple removed the Python 2 alias.

"command not found: pip" Use pip3 instead, or install it with python3 -m pip.

"command not found: code" For VS Code, open the app, press Cmd+Shift+P, and run "Shell Command: Install 'code' command in PATH."

Still Not Working?

If you've tried everything above and it's still broken, your shell configuration file might have an error. You can reset it by renaming the file and starting fresh:

mv ~/.zshrc ~/.zshrc.backup

Then open a new Terminal window. If commands work now, the problem was in your old .zshrc file. You can compare it to the backup to find what went wrong.


Keep Learning

This is one error message. If you want to understand how Terminal actually works - why PATH exists, how to navigate your Mac, what all these config files do - check out the free 9-module course at Mac Terminal for Humans.