Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

You installed nodemon but the shell says it cannot find it

Errornodemon: command not found

Short answer

The shell only finds programs in folders listed in PATH. A nodemon installed as a project dependency is not on PATH, so run it with npx or an npm script. A global install can also be missing because another Node version is active, or because the global bin folder is not in PATH.

  • Applies to nodemon 3, npm 10, Node.js 22, macOS, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find out whether nodemon is installed in this project, globally, or nowhere, and where npm puts global programs.

    npm ls nodemon
    npm ls -g nodemon
    npm prefix -g
  2. 2Match what you see, then jump to its fix

    1. 1npm ls nodemon lists it, npm ls -g nodemon does notnodemon was installed into the project, not globallyFix
    2. 2nodemon worked earlier, or in another terminal, and stopped after nvm use or a new Node installIt was installed globally under a different Node version (nvm)Fix
    3. 3npm ls -g nodemon lists it, but command -v nodemon prints nothingThe global bin folder is not in PATHFix

What does the error look like?

  • nodemon: command not found

Cause 1 of 3

nodemon was installed into the project, not globally

1Check

npm install --save-dev nodemon places the program in the project's node_modules, which is not on the system path. Typing the bare name in the terminal therefore fails, while a script in package.json works.

npm ls nodemon
ls node_modules/.bin | grep nodemon

2Fix

Start it through npx, or add a script to package.json and start that. Install it globally only if you want the bare command everywhere.

npx nodemon server.js

# package.json
"scripts": { "dev": "nodemon server.js" }

npm run dev

3Verify

The app starts and nodemon prints its watching message.

npx nodemon --version

Confirmed by github.com

Did this fix it?

Cause 2 of 3

It was installed globally under a different Node version (nvm)

1Check

With nvm, every Node version has its own global packages. A program installed while version A was active is invisible while version B is active.

nvm current
nvm ls
npm ls -g nodemon

2Fix

Install it again for the version you use now. To copy every global package from an older version, switch to the new version and run nvm reinstall-packages with the old version number.

npm install -g nodemon

# or copy all globals from an older version
nvm reinstall-packages 20.19.0

3Verify

The shell now resolves the command.

command -v nodemon

Confirmed by github.com

Did this fix it?

Cause 3 of 3

The global bin folder is not in PATH

1Check

npm links global programs into the bin folder under the global prefix on Linux and macOS. If that folder is missing from PATH, the shell cannot see anything installed there.

echo "$(npm prefix -g)/bin"
echo "$PATH" | tr ':' '\n'

2Fix

Add the bin folder printed above to PATH in your shell profile (for zsh, ~/.zshrc), then open a new terminal.

export PATH="$(npm prefix -g)/bin:$PATH"

3Verify

Open a new terminal and ask the shell where nodemon is.

command -v nodemon

Confirmed by docs.npmjs.com

Did this fix it?

How do I stop it coming back?

  • Keep nodemon as a devDependency and start it from an npm script, so a fresh clone works without any global setup.
  • Pin the Node version in the project (an .nvmrc file) so everyone uses the same version and the same set of global packages.
  • After installing a new Node version with nvm, copy your global packages with nvm reinstall-packages instead of installing them again one by one.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

npm install worked but the command is not found

bash: vite: command not found

npm puts a local install's command in the project's node_modules/.bin, which is not on your shell PATH, so run it with npx or from an npm script.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.