Troubleshoot
Node.jsErrorsLinuxServer Admin

npx: command not found — Fix for Node.js, nvm & Permission Issues

Fix 'npx: command not found' after installing Node.js. npx ships with npm 5.2+. Fix for nvm installs, old Node versions, and broken global PATH.

May 9, 2026·3 min read

npx: command not found — Fix for Node.js, nvm & Permission Issues

npx: command not found means either Node.js is not installed, you are running a version older than 5.2 (when npx was introduced), your nvm-managed Node is not on PATH, or npm is installed but the global bin directory is missing from PATH.

Step 1: Check Your Node and npm Versions

node --version   # Should be v12+ for reliable npx
npm --version    # npx is included in npm 5.2+

If node also returns command not found, Node.js is not installed at all — see the install section below.

Fix 1: Install / Upgrade Node.js

Ubuntu / Debian (via NodeSource)

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo bash -
sudo apt install -y nodejs

This installs the latest LTS with npm and npx included.

Using nvm (recommended for version management)

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc   # or ~/.zshrc
nvm install --lts
nvm use --lts

After nvm installs Node, npx will be available in the same shell.

Fix 2: nvm Installed But npx Not Found in New Shell

nvm adds itself to your shell profile (.bashrc / .zshrc) during install, but the change only takes effect in new sessions or after sourcing the file:

source ~/.bashrc
# or
source ~/.zshrc

# Then verify
npx --version

If you are inside a non-login shell (e.g. a CI job or su without -), nvm may not be loaded. Load it explicitly:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
npx --version

Fix 3: npm Installed But npx Not in PATH

Some system package managers install npm to a non-standard location. Find where npm put its binaries:

npm bin -g 2>/dev/null || npm root -g | sed 's/node_modules$/bin/'

Add that path to your PATH:

export PATH="$(npm bin -g 2>/dev/null || echo $HOME/.npm/bin):$PATH"

Make it permanent by adding it to ~/.bashrc or ~/.zshrc.

Fix 4: Old npm — Update to Get npx

If npm --version shows below 5.2, update npm:

sudo npm install -g npm@latest

Or use npx from the npm package directly until you can upgrade:

sudo npm install -g npx

Verify the Fix

npx --version
# 10.x.x or similar

# Test with a real command
npx cowsay "it works"

Common Follow-Up Errors

EACCES permission denied when running npx globally

This usually means npm's global directory is owned by root. Fix by changing the global directory to a user-writable location:

mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH="$HOME/.npm-global/bin:$PATH"
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc

npx found but runs the wrong version

which npx
nvm which current  # if using nvm

If which npx points to /usr/bin/npx (system npm) instead of your nvm-managed version, nvm's Node takes priority only if it comes first in PATH. Check and reorder if necessary.

npx: command not found — Fix for Node.js, nvm & Permission Issues | VMHeaven Troubleshoot