First published on the VMHeaven blog: npx: command not found? Fix it on Linux, macOS and Windows. The canonical points there; the full guide covers nvm, PATH, Docker and corporate proxies.
Short answer: npx ships with npm, which ships with Node.js. npx: command not found almost always means Node is either not installed or not on your PATH.
Install Node (npx comes with it)
The cleanest way is a version manager, so you are not stuck on the distro's ancient Node:
nvm (Linux / macOS) - install nvm from its repo, then:
nvm install --lts
Check all three:
node -v
npm -v
npx -v
Windows: install Node from nodejs.org or winget install OpenJS.NodeJS.LTS, then open a new terminal.
Node is installed but npx is still "not found"
-
A new shell is needed. nvm adds Node to PATH in
~/.bashrc/~/.zshrc; open a new terminal orsourcethe file. -
zsh: command not found: npxon macOS - the nvm or Homebrew line is missing from~/.zshrc. Add it back. -
In a Docker image - use an official
node:base image. A baredebianoralpineimage has no Node, so npm and npx are absent. -
Very old npm (< 5.2) never had npx:
npm install -g npm@latest, or usenpm execinstead.
Full guide
nvm vs fnm vs the distro package, the deprecated standalone npx package, proxies and every OS are in the complete version:
npx: command not found - the complete fix
Need a clean box to try this on? A Node-ready Ubuntu VPS spins up in a minute.
Top comments (0)