Skip to content
npm: command not found

npm: command not found

DodaTech 2 min read

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 nvm but 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 | bash

Restart your terminal, then install the latest LTS Node.js:

nvm install --lts
nvm use --lts

Verify it worked:

node --version   # e.g., v22.14.0
npm --version    # e.g., 10.9.2

2. 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 nodejs

Fedora / RHEL:

sudo dnf install nodejs

Arch Linux:

sudo pacman -S nodejs npm

4. Activate nvm if already installed

If you have nvm installed but get the error:

source ~/.bashrc
nvm use --lts

Or run the nvm activation command manually:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
Is npm the same as Node.js?
No, but npm ships with Node.js — the npm CLI is bundled into the Node.js installer since v0.6.3. You only need to install Node.js, and npm comes along with it. Installing npm standalone is possible but rarely needed.
Why can I run node but not npm?
This is unusual but can happen if only the Node.js binary was placed in PATH (e.g., a manual install) or if the npm wrapper script is missing. Reinstall Node.js from the official installer or use nvm to get both binaries in sync.
Does this error mean npm is broken or missing?
It means the shell can’t find the npm command anywhere in your PATH directories. It could be missing, moved, or the PATH variable could be misconfigured. Running which npm (Linux/macOS) or where npm (Windows) will confirm whether the binary exists but is not in PATH.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro