npm Command Not Found: Check Node.js, npm and PATH
“npm: command not found” or “npm is not recognized” is a command-discovery failure, not an npm package error. First determine whether node and npm are both missing, only npm is missing, or the current shell is resolving the wrong Node installation. Do that before reinstalling Node or editing PATH.
node and npm paths; use one installation/version-manager context before making more PATH edits.First-party shell reproduction on Oct 29, 2026 (Node.js v24.22.1, npm 11.9.0): env -i PATH=/nonexistent /bin/sh -c 'npm --version' returned /bin/sh: 1: npm: not found (exit 127). With the normal PATH, this host resolved Node and npm from the same runtime directory. This confirms that a shell can report this error when npm is not on its active PATH; it does not prove npm is uninstalled. The important comparison is node and npm together, not npm alone.
Windows Command Prompt:
where node
where npm
Windows PowerShell:
where.exe node
where.exe npm
Get-Command node, npm -ErrorAction SilentlyContinue
macOS/Linux:
command -v node
command -v npmInterpret: neither path → installation/version-manager activation first. Node path only → npm is missing from or not exposed by that Node installation. Both paths → compare whether they belong to the same intended installation/version-manager context before changing PATH.
Why this happens
The shell can run npm only when the npm launcher for the active Node installation is reachable in that process environment. npm's own installation guidance treats Node.js and npm as a pair and recommends a Node version manager where practical. A fresh installer or version-manager change can require a new shell because an already-running terminal keeps its existing environment and shell state.
Diagnose before changing more
Run node --version. If Node.js is also missing, fix the Node.js installation before treating npm as a separate problem.
Close the terminal completely and open a new one so the shell reads the updated environment.
If a path exists, inspect which installation it points to before reinstalling anything.
If paths point to different Node installations/version managers, fix that ambiguity before adding more PATH entries.
Inspect that environment directly. Version-manager initialization and profile loading are process/shell-specific.
Fix #2 — both node and npm are missing
If neither command resolves in the failing shell, first determine how Node is supposed to be supplied on that machine: a version manager, OS/package manager, or Node installer. npm documents installing Node.js and npm together and recommends a Node version manager where practical. Repair that intended installation path rather than layering a second unrelated Node installation on top.
Verify: Open a fresh terminal and run node -v and npm -v. Both should return versions from the installation you intended to use.
Fix #3 — node works, but npm is missing
If node -v succeeds but npm does not resolve, do not treat this as a generic PATH failure yet. Identify the resolved Node binary and the installation method that owns it. Standard Node installations normally provide npm; a partial/broken installation, distribution-specific packaging, or mixed install paths can leave Node available while the expected npm launcher is absent.
Verify: after repairing the owning installation, a fresh shell should resolve node and npm from the same intended toolchain and both version commands should succeed.
Fix #4 — nvm is installed, but this shell did not load it
On macOS/Linux/WSL, nvm is a sourced shell function rather than a standalone executable. Its installer adds initialization to a shell profile such as ~/.bashrc or ~/.zshrc. If the wrong profile was edited—or the current terminal predates that change—nvm, Node and npm can all appear missing. Use command -v nvm to test nvm; which nvm is not the correct verification because nvm is a function.
command -v nvm
node -v
npm -vIf nvm was just installed, open a new terminal or source the profile that your current shell actually uses. Do not blindly append the nvm initialization snippet to every profile file.
Verify: the new shell loads nvm, selects the intended Node version, and both Node and npm resolve.
Fix #5 — interactive terminal works, CI/Docker does not
Do not use your laptop's successful npm -v as evidence for a failing job/container. Run command discovery and version checks inside the failing environment. In particular, nvm documents that non-interactive bash sessions such as Docker builds do not source normal profile files automatically; if your build depends on nvm, its initialization must be appropriate for that non-interactive shell.
command -v node || true
command -v npm || true
node -v
npm -vFor container builds, prefer making Node/npm availability explicit in the build image/stage rather than depending accidentally on a developer's interactive shell profile.
Verify: rerun the exact CI step or container build that previously failed—not merely an interactive shell on the host.
What not to do
which nvm proves nvm is absent; nvm is normally a sourced shell function, so use command -v nvm.Do not copy interactive-shell PATH/profile assumptions into CI or Docker without checking what that process actually loads.Still seeing the error?
Compare the resolved Node path, npm path, versions, shell and installation method. If multiple installations exist, remove the ambiguity before making more PATH changes. If only a non-interactive environment fails, capture its own environment rather than debugging from a working host terminal.
node -v and npm -v where availableoutput of where node + where npm (Windows), or command -v node + command -v npm (macOS/Linux)how Node.js was installed (installer, nvm, nvm-windows, package manager)whether a new terminal session changes the resultcurrent shell and relevant profile/version-manager initializationwhether failure occurs only in IDE terminal, CI, SSH, WSL or DockerReferences and related guides
Still stuck? Ask the community
Share your operating system, software version, exact error text, and which fix you already tried. Another reader may have seen the same setup.
Loading community discussion…
Comments could not load here. Open ErrorHarbor Discussions on GitHub →