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 notice access token expired or revoked. Please try logging in again.
Token has expired - npm authentication failure
npm ERR! code EAI_AGAIN
How to fix "EAI_AGAIN" in npm
npm error code E403 npm error 403 Forbidden - PUT https://registry.npmjs.org/<package>
How to fix 'E403 Forbidden' error in npm
npm ERR! code EUSAGE npm ERR! Usage error
How to fix "npm ERR! code EUSAGE" in Node.js projects
npm ERR! code E401 npm ERR! 401 Unauthorized
How to fix "E401 Unauthorized" in npm