🔧 Error Fixes

command not found — How to Fix PATH Issues in Your Terminal


zsh: command not found: node
bash: command not found: python

Your terminal can’t find the program you’re trying to run. It’s either not installed, or it’s not in your PATH.

What PATH Is

PATH is a list of directories your terminal searches when you type a command. When you type node, it checks each directory in PATH until it finds a node executable.

# See your current PATH
echo $PATH

# It looks like:
# /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Fix 1: The Tool Isn’t Installed

# Check if it's installed anywhere
which node          # shows path or "not found"
where node          # shows all locations (zsh)
command -v node     # portable check

# Install it
# Mac
brew install node

# Ubuntu/Debian
sudo apt install nodejs

# Python
brew install python3    # Mac
sudo apt install python3  # Linux

Fix 2: Add to PATH

The tool is installed but not in a directory that’s in your PATH.

# Find where it is
find / -name "node" -type f 2>/dev/null
# or
ls /usr/local/bin/ | grep node

Add to PATH temporarily (current session only):

export PATH="/path/to/directory:$PATH"

Add to PATH permanently:

For zsh (default on Mac):

echo 'export PATH="/path/to/directory:$PATH"' >> ~/.zshrc
source ~/.zshrc

For bash:

echo 'export PATH="/path/to/directory:$PATH"' >> ~/.bashrc
source ~/.bashrc

Fix 3: nvm / pyenv Not Loaded

If you installed Node via nvm or Python via pyenv, they need to be loaded in your shell config.

nvm:

# Add to ~/.zshrc or ~/.bashrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

pyenv:

# Add to ~/.zshrc or ~/.bashrc
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

Then restart your terminal or source the config file.

Fix 4: Wrong Shell Config File

A common mistake: you added the PATH to .bashrc but your terminal uses zsh (or vice versa).

# Check which shell you're using
echo $SHELL
# /bin/zsh → edit ~/.zshrc
# /bin/bash → edit ~/.bashrc

Mac users: macOS defaults to zsh since Catalina. If you added PATH to .bash_profile or .bashrc, it won’t work. Use .zshrc.

Fix 5: New Terminal Tab Needed

After installing something, your current terminal session doesn’t know about it. Either:

# Reload your config
source ~/.zshrc

# Or just open a new terminal tab/window

Fix 6: Homebrew Not in PATH (Mac)

After installing Homebrew on Apple Silicon Macs:

# Homebrew installs to /opt/homebrew, not /usr/local
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
source ~/.zshrc

Debugging Checklist

# 1. Which shell am I using?
echo $SHELL

# 2. What's in my PATH?
echo $PATH | tr ':' '\n'

# 3. Where is the command?
which <command>
find /usr -name "<command>" -type f 2>/dev/null

# 4. Is my shell config loading?
cat ~/.zshrc | grep PATH