Fix My Error

Stuck? Solved.

Home › Fix Errors › npm › Command Not Found
zsh: command not found: npm — OR — 'npm' is not recognized

Fix: npm Command Not Found

Your terminal doesn't know what npm is. Two reasons: Node.js isn't installed, or its bin directory isn't on your PATH.

Last updated: October 2026

⚡ The 30-second diagnostic

Run these two commands to find out which problem you have:

node --version    # prints v22.x.x if installed

which npm         # macOS/Linux — prints path if found
where npm         # Windows — prints path if found

If node --version fails: Node.js isn't installed → see fix #1 below.
If node works but npm doesn't: PATH issue → see fix #2 below.

Two causes, two fixes

1

Node.js is not installed

node --version says "command not found" too. You need to install Node.js — npm comes bundled with it.

Best method — nvm (all platforms except Windows):

# Install nvm (macOS/Linux)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# Reload shell
source ~/.zshrc    # macOS/zsh
source ~/.bashrc   # Linux/bash

# Install latest Node LTS (includes npm)
nvm install --lts
nvm use --lts

# Verify
node --version    # → v22.x.x
npm --version     # → 10.x.x

macOS alternative — Homebrew:

brew install node

Windows:

Download the LTS installer from nodejs.org. During install, ensure "Add to PATH" is checked (it's default). Restart your terminal after install.

Why nvm over a system install? nvm keeps Node in your home folder — no permission issues, and you can switch Node versions per project.

2

Node is installed, but npm isn't on PATH

node --version works, but npm doesn't. The shell can't find npm's binary. Find where it lives and add that directory to PATH.

Step 1 — find npm's location:

# macOS / Linux
find / -name npm -type f 2>/dev/null | head

# Common locations:
# /usr/local/bin/npm
# ~/.nvm/versions/node/v22.x.x/bin/npm
# /opt/homebrew/bin/npm   (Apple Silicon Homebrew)

# Windows (in PowerShell)
where.exe npm

Step 2 — add to PATH:

# macOS / zsh — edit ~/.zshrc
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

# Linux / bash — edit ~/.bashrc
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

# Verify
which npm
npm --version

Windows — add to PATH via GUI:

  1. Press Win+R, type sysdm.cpl, press Enter
  2. Advanced tab → Environment Variables
  3. Under "User variables," find "Path" → Edit
  4. Click New, paste the folder containing npm.cmd (usually C:\Program Files\nodejs)
  5. OK → OK → OK
  6. Close and reopen your terminal

Platform-specific gotchas

🍎 macOS
  • If you use zsh (default since Catalina), edit ~/.zshrc, not ~/.bashrc
  • Homebrew on Apple Silicon installs to /opt/homebrew/bin, not /usr/local/bin
  • Run brew doctor if the PATH looks wrong
  • After installing Node with the official .pkg installer, restart your terminal — PATH updates load on shell start
🐧 Linux
  • Snap installs of Node sometimes have PATH issues — prefer nvm or apt
  • If you installed via apt install nodejs npm, verify with dpkg -l | grep node
  • WSL users: install nvm inside WSL, not on Windows
  • Reload PATH with source ~/.bashrc or open a new terminal
🪟 Windows
  • Use where instead of which
  • Use nvm-windows from github.com/coreybutler/nvm-windows for version management
  • Restart the terminal after installing Node — Windows doesn't reload PATH automatically
  • PowerShell may require Set-ExecutionPolicy for some npm scripts
💻 VS Code integrated terminal
  • Reload the window after installing Node (Command Palette → "Developer: Reload Window")
  • If other terminals work but VS Code's doesn't, that terminal has a stale PATH
  • Restart the whole VS Code app, not just the terminal

✅ Verify everything works

After any fix, run these commands. All four should return without errors.

# 1. Node is installed
node --version

# 2. npm is installed and on PATH
npm --version

# 3. Both are pointing to the same Node install
which node        # macOS/Linux
which npm
where node        # Windows
where npm

# 4. npm can install a package
npm install -g typescript

# 5. The installed CLI tool works
tsc --version

If step 4 fails with EACCES, you have a permission issue on top of the PATH issue. See the permission denied fix.

❓ Frequently asked questions

Why does my terminal say npm command not found?

Three possibilities: Node.js isn't installed, Node is installed but npm's bin directory isn't on your PATH, or you installed Node via a package manager (like snap or Homebrew) that didn't update your shell config. Check with 'which node' or 'node --version' first.

How do I install Node.js and npm?

The recommended way is nvm (Node Version Manager). Run the install script from nvm's GitHub, then 'nvm install --lts'. This installs Node and npm into your home directory with no permission issues. Alternatives: Homebrew on macOS, package manager on Linux, official installer on Windows.

What does 'npm is not recognized as an internal command' mean on Windows?

Windows can't find npm.exe in your PATH. Usually Node.js wasn't added to PATH during install, or you need to restart your terminal after installing. Check System Properties → Environment Variables → Path for a Node.js entry.

I installed Node but npm still not found — what now?

Your shell doesn't know where npm lives. Find Node's install location ('which node' or 'where node'), then add its directory to your PATH in .zshrc, .bashrc, or .bash_profile. Reload the shell with 'source ~/.zshrc'.

Does Homebrew's Node install include npm?

Yes. Homebrew installs Node with npm bundled. If npm isn't found after 'brew install node', run 'brew unlink node && brew link --overwrite node' — Homebrew sometimes leaves the binary unlinked. Or 'brew doctor' to diagnose PATH issues.

🔗 Related fixes

← All npm Fixes