npm: command not found and node Is Not Recognized
Your shell prints npm: command not found, or Windows says node is not recognized, when it cannot find the program in any folder listed in PATH. Either Node.js is not installed, it was installed after this terminal opened, or its folder never made it into PATH. npm ships with Node, so fixing node fixes both.
| Install method | Folder that must be on PATH | Check with |
|---|---|---|
| Official installer, Mac | /usr/local/bin | which node |
| Homebrew, Apple silicon | /opt/homebrew/bin | brew --prefix |
| nvm, Mac or Linux | ~/.nvm/versions/node/<version>/bin | nvm current |
| Official installer, Windows | C:\Program Files\nodejs\ | where node |
| nvm-windows | The NVM_SYMLINK folder | nvm list |
Updated
PATH is the list of folders a shell searches when you type a command. Installing Node puts files on disk; it only works from the terminal once their folder is on that list and the shell has reloaded it. Most fixes come down to one of those two steps.
Add Node to PATH
Mac: Homebrew and nvm lines for zsh
Use the block that matches how you installed Node, then open a new terminal.
# Homebrew on Apple silicon, in ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
# nvm, in ~/.zshrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
node -v && npm -vWindows: check where node is found
PowerShell. If nothing prints, add the nodejs folder to Path in System Properties, then open a new window.
where.exe node
$env:Path -split ";" | Select-String nodejs
node -v; npm -v
Mac and Linux
Run echo $PATH and look for the folder from the table. If node exists on disk but its folder is absent, add an export line to the startup file for your shell and reload it. Avoid sudo npm installs; permission errors there usually mean a manager like nvm is the better route.
In CI and cron jobs, the shell is not interactive and may skip your profile files. Use the full path to node or load nvm explicitly in the script.
Windows
Run where node in Command Prompt. If it prints nothing, open Edit the system environment variables, click Environment Variables, select Path and add the nodejs folder. Programs that were already open keep the old value until restarted.
Building a site with We.Inc needs no Node install at all, which is handy on a locked-down work laptop where you cannot change PATH.
How it works
- Close every terminal and editor window, open a new one, and run node -v.
- If it still fails, check whether Node is installed at the folder in the table.
- Install Node if it is missing, or add its folder to PATH if it is not on the list.
- Open a fresh terminal and confirm with node -v and npm -v.
Tips
- VS Code's built-in terminal inherits PATH from when VS Code started. Restart the whole editor, not just the terminal panel.
- With nvm, a new shell has no Node until nvm.sh loads. If nvm itself is missing, the install script's lines never reached ~/.zshrc or ~/.bashrc.
- macOS has used zsh by default since Catalina, so PATH lines placed only in ~/.bash_profile are ignored.
- On Windows, keep the Add to PATH option checked in the Node installer. If you unchecked it, rerun the installer and choose Repair.
Frequently asked questions
Why does it say npm command not found after installing Node?
The terminal you are using was opened before the install, so it still has the old PATH. Open a new terminal. If that fails, the install folder is not on PATH and needs adding.
How do I fix node is not recognized as an internal or external command?
Install Node from nodejs.org, or add C:\Program Files\nodejs\ to the Path variable under System Properties, Environment Variables. Then close and reopen Command Prompt or PowerShell and run node -v.
How do I fix zsh: command not found: npm on a Mac?
Install Node with the official installer, Homebrew or nvm. For Homebrew on Apple silicon, add the brew shellenv line to ~/.zprofile. For nvm, make sure its loading lines are in ~/.zshrc, then run source ~/.zshrc.
node works but npm does not. Why?
Some Linux distribution packages split npm into its own package. Install it with your package manager, for example sudo apt install npm, or switch to nvm, which installs both together.
Related: Install Node and npm on a Mac, npm commands cheat sheet, pnpm vs npm, localhost:3000.
Build your site free or see all free tools. On We.Inc you can build your site free, with no card and no trial needed to start. AI building is on paid plans from $20 a month.
More in Guides
- npm Commands Cheat Sheet
- OAuth Explained: Roles, the PKCE Flow, and OAuth vs SAML
- One-Click Unsubscribe: Headers, Rules and a Builder
- Open Graph Tags Explained
- Open-Source AI Agent Frameworks, Compared
- How to Optimize Images for a Website
- Order Confirmation Email Template
- Orphan Pages: How to Find and Fix Pages Nothing Links To
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App