You installed nodemon but the shell says it cannot find it
nodemon: command not foundShort 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.
Fix it fast
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 -g2Match what you see, then jump to its fix
- 1
npm ls nodemon lists it, npm ls -g nodemon does notnodemon was installed into the project, not globallyFix - 2
nodemon 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
npm ls -g nodemon lists it, but command -v nodemon prints nothingThe global bin folder is not in PATHFix
- 1
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 nodemon2Fix
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 dev3Verify
The app starts and nodemon prints its watching message.
npx nodemon --versionConfirmed by github.com
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 nodemon2Fix
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.03Verify
The shell now resolves the command.
command -v nodemonConfirmed by github.com
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 nodemonConfirmed by docs.npmjs.com
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
nodemon says the app crashed and stops restarting
[nodemon] clean exit - waiting for changes before restart
Nodemon prints this when your script exits with a non-zero code.
3 causes, each with a fixBack 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 fixBack end
Application Load Balancer returns 502 for a Node.js target
HTTPCode_ELB_502_Count
An ALB returns 502 when the target gives it something it cannot use: a refused or reset connection, a connection closed mid-request, a bad response, or a header over 32 K.
4 causes, each with a fixBack end
corepack enable fails: permission denied while creating the pnpm link
Internal Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/usr/local/bin/pnpm'
corepack enable writes small link files for yarn and pnpm next to your node binary.
2 causes, each with a fixBack end
Create React App says Node is too old, and npm will not run on the new one
npm does not support Node.js v10.19.0
The shell is running an old Node.js that is below the version Create React App needs.
3 causes, each with a fixBack end
firebase deploy cannot load your functions: user code failed to load
Functions codebase could not be analyzed successfully. It may have a syntax or runtime error
The Firebase CLI loads your functions code on your machine before it deploys, to learn which functions exist.
4 causes, each with a fix