Blog
3 min read

"Command Not Found": The PATH Variable Explained

"command not found" or "is not recognized as an internal or external command" usually means the program is installed but your terminal doesn't know where to look. How PATH works on Mac, Linux and Windows, how to check it, and how to add a folder permanently.

zsh: command not found: claude
bash: node: command not found
'npm' is not recognized as an internal or external command, operable program or batch file.

You just installed it. So why can't your terminal find it? Almost always, the answer is PATH.

What PATH is

When you type a command like node, your terminal doesn't search your whole computer. It checks a short list of folders, in order, and runs the first matching program it finds. That list is an environment variable called PATH. (Environment variables explained)

See yours:

echo $PATH          # macOS / Linux
$env:Path -split ';'   # Windows PowerShell

On Mac/Linux it's folders separated by :, like:

/Users/you/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin

If the program lives in a folder that isn't on that list, you get "command not found."

Step 1: Open a new terminal

Installers often add a folder to PATH by editing a settings file. Terminals only read those files when they start. Close the window, open a new one, try again. This fixes it more often than anything else.

Step 2: Check whether it's installed, and where

which node           # macOS / Linux: prints the path if found
ls ~/.local/bin      # common install location for CLI tools
Get-Command node     # Windows
where.exe node

If you find the program somewhere but which doesn't, that folder isn't on PATH.

Common install locations:

Installed with Usually goes in
Homebrew (Apple Silicon Mac) /opt/homebrew/bin
Homebrew (Intel Mac) /usr/local/bin
Native installers (Claude Code and others) ~/.local/bin
npm global packages $(npm prefix -g)/bin
Python pip install --user ~/.local/bin
nvm (Node versions) ~/.nvm/versions/node/<version>/bin

Step 3: Add the folder to PATH permanently

macOS (zsh, the default shell)

Add a line to ~/.zshrc:

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Linux (bash)

Same idea, in ~/.bashrc:

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Note the :$PATH at the end — it adds your folder to the existing list. Forgetting it replaces your whole PATH, and suddenly even ls is "not found." (If that happens, open a new terminal and fix the file.)

Windows

Search the Start menu for "Edit environment variables for your account" → select Path → Edit → New → paste the folder → OK. Then open a new terminal.

Which shell file?

Your shell decides which file it reads:

echo $SHELL
  • /bin/zsh → ~/.zshrc
  • /bin/bash → ~/.bashrc (Linux) or ~/.bash_profile (older macOS)
  • fish → fish_add_path

Editing the wrong file is a common reason "I added it and it still doesn't work."

When the wrong version runs

PATH order matters: the first match wins. If you have Node from Homebrew and from nvm, whichever folder comes first is the one you get.

which -a node      # list every match, in order

Reorder PATH or uninstall the copy you don't want. Tools like claude doctor flag duplicate installs. (Claude Code troubleshooting)

Don't fix it with sudo

If a global npm install fails with permission errors, don't use sudo npm install -g. It installs into system folders and causes permission problems later. Use a Node version manager (nvm, fnm, Volta) so global packages live in your home folder. (What is Node.js?)

The summary

  • PATH is the list of folders your terminal searches for commands.
  • Open a new terminal first.
  • Find where the program is installed; if that folder isn't on PATH, add it in your shell's config file (with :$PATH).
  • which -a shows which copy runs when there are several.

EasySpawn gives you a persistent server with Node, Git and Claude Code installed and on the PATH already, so you can skip straight to building. See how it works or join the waitlist.

Related: The Terminal for Complete Beginners · How to Install Claude Code · Environment Variables Explained · Bash Scripting for Beginners

Keep reading