npmNode.jsError Fix2026 Updated

npm: command not found— Fixed [Complete Guide 2026]

January 20265 min readmacOS · Windows · Linux

⚡ Try This First

Open a brand new terminal window and run:

npm --version

If that works — your old terminal window just needed refreshing. If not, keep reading.

Why Does npm: command not found Happen?

Terminal Error
npm: command not found
# or on Windows:
'npm' is not recognized as an internal or external command,
operable program or batch file.

npm ships bundled with Node.js. This error means your terminal cannot find the npm executable. There are four possible reasons, and the fix depends on which one applies to you:

CauseFix
Node.js is not installedFix 1 or Fix 2
Node installed but PATH not updatedFix 3
Terminal window was open before installFix 5 — open new terminal
Windows installer did not add to PATHFix 4

Diagnose in 30 Seconds

terminal
# Step 1: Is Node.js installed?
node --version
# If this returns v20.x.x — Node is installed
# If this also says command not found — Node is NOT installed

# Step 2: Is npm somewhere on your system?
which npm        # macOS / Linux
where npm        # Windows
# If this returns a path — npm is installed but not in PATH
# If this returns nothing — npm is not installed at all

The single most common cause of this error: you just installed Node.js but are still in the same terminal window that was open before the install. The fix is simply opening a new terminal window.

1

Install Node.js via nvm (Recommended)

Best permanent fix — handles PATH automatically
5 min

nvm (Node Version Manager) is the cleanest way to install Node and npm. It installs everything in your home directory with automatic PATH configuration — no sudo, no permission issues, and you can switch Node versions instantly.

macOS / Linux

terminal
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash

# Reload your shell config
source ~/.zshrc    # zsh (default on macOS)
source ~/.bashrc   # bash

# Install latest LTS Node + npm
nvm install --lts
nvm use --lts

# Make it default for all new terminals
nvm alias default node

# Verify both installed
node --version
npm --version

Windows

Windows uses a separate project called nvm-windows. Download the installer from github.com/coreybutler/nvm-windows — it provides the same commands as nvm on Unix.

PowerShell (after nvm-windows install)
nvm install lts
nvm use lts
npm --version

nvm installs Node in your home directory (~/.nvm) where you always have full write access — eliminating permission issues forever.

2

Install Node.js Directly

macOS / Linux / Windows — official installer
3 min

macOS — via Homebrew

terminal
brew install node

# Verify
node --version
npm --version

Ubuntu / Debian Linux

terminal
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs

# Verify
node --version
npm --version

Windows — official installer

  • Download latest LTS installer from nodejs.org
  • Run the .msi installer
  • Make sure 'Add to PATH' is checked during installation
  • Open a NEW terminal window after installation
  • Verify: node --version && npm --version

On macOS, do not mix Homebrew Node and nvm Node. Pick one installation method and stick to it — having both causes version conflicts and PATH confusion.

3

Fix PATH Not Set Correctly

Node is installed but npm still not found
3 min

If node --version works but npm --version says command not found, npm is installed but its location is not in your PATH.

Find where npm is installed

terminal
# Find Node's bin directory
node -e "console.log(require('path').dirname(process.execPath))"

# Find npm specifically
find /usr /usr/local -name 'npm' 2>/dev/null

Add to PATH — macOS / Linux

~/.zshrc or ~/.bashrc
# Add Node bin to PATH
export PATH="/usr/local/bin:$PATH"

# Or with the path from the command above:
export PATH="/home/youruser/.nvm/versions/node/v20.0.0/bin:$PATH"
terminal
# Reload shell config
source ~/.zshrc

# Verify
npm --version

Always open a new terminal after editing PATH — existing windows do not pick up changes until reloaded.

4

Fix on Windows — Add to PATH

Windows specific
5 min

On Windows, npm not found after installing Node.js means the installer did not add Node's directory to the system PATH, or the PATH change has not been picked up by your current terminal.

Check if Node is installed but not in PATH

cmd
# Check if Node exists at default location
dir "C:\Program Files\nodejs\npm.cmd"
# If this shows the file, Node is installed — just not in PATH

Add Node to PATH via System Properties

  • Press Windows + R, type sysdm.cpl, press Enter
  • Click Advanced tab → Environment Variables
  • Under System Variables, select Path → click Edit
  • Click New and add: C:\Program Files\nodejs
  • Click OK on all dialogs
  • Open a NEW terminal window
  • Verify: npm --version

Or via PowerShell (Administrator)

PowerShell (Administrator)
[Environment]::SetEnvironmentVariable(
  "Path",
  $env:Path + ";C:\Program Files\nodejs",
  "Machine"
)
# Then open new terminal and verify
npm --version

Always open a brand new terminal window after modifying PATH on Windows. The currently open window will not see the change.

5

Open a New Terminal Window

After any Node.js installation or PATH change
10 seconds

This is the most commonly overlooked fix — and solves the problem 40% of the time. When you install Node.js or change PATH, your currently open terminal window does not know about it. The shell loads PATH once when it starts.

terminal
# Close your current terminal completely
# Open a brand new terminal window
# Then verify:
node --version
npm --version

On macOS: Cmd+Q to fully quit Terminal, then reopen it. Just closing the tab is not enough — the parent process must be restarted.

OS-Specific Notes

macOS

macOS Catalina and later uses zsh as the default shell. If you added PATH to ~/.bashrc it will not work — add it to ~/.zshrc instead. After any change run source ~/.zshrc and open a new terminal.

Windows

If you have both a standalone Node.js installation and Node installed via another tool like Chocolatey or winget, they can conflict with each other in PATH. Uninstall all but one and use nvm-windows going forward.

Linux

The apt package for nodejs on Ubuntu is often outdated (sometimes as old as Node 12). Always use the NodeSource repository or nvm to get a current LTS version on Linux.

terminal
# Check your Node version
node --version
# If below v18 — upgrade immediately via NodeSource or nvm

How to Prevent This Error

Quick Diagnosis — Work Through in Order

  1. 1

    Open a new terminal window and retry npm --version

    Fixes it 40% of the time — try this first

  2. 2

    node --version — does it return a version?

    If yes: PATH issue (Fix 3). If no: not installed (Fix 1)

  3. 3

    Install Node via nvm

    Best permanent fix for macOS/Linux

  4. 4

    Install via official nodejs.org installer (Windows)

    Check Add to PATH during install

  5. 5

    Add Node bin directory to PATH manually

    Fix 3 — edit .zshrc or Environment Variables

Frequently Asked Questions

Why does npm command not found happen after installing Node.js?+
The most common reason is that your terminal window was open before Node was installed. PATH changes are not picked up by existing terminal sessions. Open a brand new terminal window and npm will be found.
How do I fix npm command not found on Mac?+
The fastest fix on Mac is installing Node via nvm. Run the nvm install script, source your shell config (source ~/.zshrc), then nvm install --lts. This installs Node and npm with correct PATH setup automatically.
How do I fix npm command not found on Ubuntu Linux?+
Run: curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && sudo apt install -y nodejs. This installs the latest LTS Node and npm from the NodeSource repository.
npm not recognized in Windows — how to fix?+
Go to System Properties → Environment Variables → Path and add C:\Program Files\nodejs to the list. Then open a new Command Prompt or PowerShell window and run npm again.
Node is installed but npm says command not found — why?+
npm might be in a location not in your PATH. Run: node -e "console.log(require('path').dirname(process.execPath))" to find where Node is, then add that path to PATH.
How do I check if npm is installed correctly?+
Run npm --version in a new terminal window. If it prints a version like 10.x.x, npm is working correctly. If it says command not found, follow Fix 1 or Fix 3 above.

Need Expert Help?

We Build Production-Grade Next.js & Node.js Apps

Softplix is a full-stack development agency. Struggling with Node.js environment issues in production? We can fix your setup.

Talk to an Engineer