How to Fix zsh: command not found: nodemon

The zsh: command not found: nodemon error occurs when the “nodemon command is unavailable in your zsh shell’s PATH or nodemon is not installed in your system.”

Common reasons for the error

  1. Nodemon is not installed in your system.
  2. Nodemon is available in a different path.
  3. Nodemon utility is not installed globally.

How to fix the command not found: nodemon error

Here are five solutions to fix the command not found: nodemon error.

  1. Check if a nodemon is installed.
  2. Install nodemon; if not installed.
  3. Check the path.
  4. Add npm’s global bin directory to PATH.
  5. Local installation.

Solution 1: Check if nodemon is installed

You can use the following command to check if nodemon is installed globally:

npm list -g --depth=0 | grep nodemon

Solution 2: Install nodemon; if not installed

If nodemon is not installed, you can install it globally using:

npm install -g nodemon

How to install nodemon in Ubuntu or Mac OS correctly

Run the npm command to install nodemon globally in the system path.

sudo npm install -g nodemon

How to install nodemon in Windows correctly

Run the following command to install nodemon globally in Windows 10.

C:\> npm install -g nodemon

Solution 3: Check the PATH

After installing, if you’re still facing the issue, it’s possible that the directory where global npm packages are installed is not in your shell’s PATH. You can check your PATH using:

echo $PATH

Solution 4: Add npm’s global bin directory to PATH

If the directory where nodemon is installed is not in the PATH, you can add it. Usually, global npm packages are installed in ~/.npm-global/bin or /usr/local/bin.

You can add it to the PATH by adding the following lines to your ~/.zshrc file:

export PATH=$PATH:~/.npm-global/bin

After adding, reload the .zshrc file using:

source ~/.zshrc

Solution 5: Local Installation

If you’ve installed nodemon locally in your project (i.e., as a dev dependency), you won’t be able to run it directly from the command line unless you use npx or specify the full path to the nodemon binary in the node_modules directory.

To run a locally installed nodemon, you can use:

npx nodemon

I hope one of these solutions works for you!