npm: command not found
The npm: command not found error means npm is missing from your PATH. Fix it by installing Node.js via nvm, a package manager, or the official installer.
What It Means
The shell cannot locate the npm binary in any of the directories listed in the PATH environment variable. This almost always means Node.js and npm are not installed — npm ships as part of Node.js since version 0.6.3, so you rarely need to install it separately.
Why It Happens
- Node.js was never installed on the machine.
- Node.js was installed but npm is missing from the
PATH(e.g., installed for a different user, or the install was corrupted). - You’re using a Node.js version manager like
nvmbut haven’t activated a Node version. - The npm symlink is broken after a partial upgrade or removal.
How to Fix It
1. Install Node.js via nvm (recommended for developers)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bashRestart your terminal, then install the latest LTS Node.js:
nvm install --lts
nvm use --ltsVerify it worked:
node --version # e.g., v22.14.0
npm --version # e.g., 10.9.22. Install via official installer (Windows / macOS)
Download the LTS installer from nodejs.org and run it. The installer adds Node.js and npm to your PATH automatically.
3. Install via package manager (Linux)
Ubuntu / Debian:
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejsFedora / RHEL:
sudo dnf install nodejsArch Linux:
sudo pacman -S nodejs npm4. Activate nvm if already installed
If you have nvm installed but get the error:
source ~/.bashrc
nvm use --ltsOr run the nvm activation command manually:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro