The "npx: command not found" error occurs when npx is not installed or not in your system PATH. npx comes bundled with npm 5.2.0+ and is used to run package binaries without global installation.
npx is a package runner that comes bundled with npm (version 5.2.0 and later). It allows you to run CLI tools from npm packages without installing them globally. When you see "npx: command not found," either: 1. npm is too old (pre-5.2.0) and doesn't include npx 2. npm's bin directory isn't in your system PATH 3. Node.js/npm installation is incomplete or corrupted npx is particularly useful for running one-off commands (like create-react-app) or using different versions of tools per project.
Verify npm version (needs 5.2.0+):
npm --versionIf below 5.2.0, upgrade:
npm install -g npm@latestIf npx is still missing:
npm install -g npx
npx --versionGet npm's bin directory and add to PATH:
# Find npm prefix
npm config get prefix
# Add to PATH (Linux/macOS)
# Add this to ~/.bashrc or ~/.zshrc:
export PATH=$(npm config get prefix)/bin:$PATH
source ~/.bashrcWindows: Add the npm path to System Environment Variables.
If using nvm, ensure proper shell integration:
# Add to ~/.bashrc or ~/.zshrc:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# Reload
source ~/.bashrc
# Test
npx --versionIf still not working, reinstall Node.js:
macOS (Homebrew):
brew uninstall node
brew install nodeWindows/Linux: Download installer from nodejs.org and run.
Verify:
node --version
npm --version
npx --versionnpx vs npm install -g:
Use npx when:
- Running a command once (npx create-react-app my-app)
- You want the latest version always
- Avoiding global package pollution
Use npm install -g when:
- You use the tool frequently
- You need a specific version consistently
- The tool doesn't change often
npx first checks local node_modules/.bin, then global packages, then downloads from npm if needed.
npm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error