How to Solve Nodemon Command Not Found Error in Linux Bash

Yahya Irmak Mar 14, 2025 Bash Bash Error
  1. Understanding the nodemon Command Not Found Error
  2. Method 1: Installing Nodemon Globally
  3. Method 2: Checking and Updating the PATH Variable
  4. Method 3: Local Installation of Nodemon
  5. Conclusion
  6. FAQ
How to Solve Nodemon Command Not Found Error in Linux Bash

If you’re a developer working with Node.js, you’ve likely come across Nodemon, a tool that automatically restarts your application when file changes are detected. However, encountering the “nodemon command not found” error in Linux Bash can be frustrating. This error typically arises due to either Nodemon not being installed globally or issues with your system’s PATH variable.

In this article, we’ll walk you through various methods to resolve this issue effectively. Whether you’re a seasoned developer or a beginner, our straightforward solutions will help you get Nodemon up and running in no time.

Understanding the nodemon Command Not Found Error

Before diving into solutions, it’s essential to understand why you might encounter the “nodemon command not found” error. This error usually occurs for a couple of reasons:

  1. Nodemon is not installed globally on your system.
  2. The PATH environment variable does not include the directory where Nodemon is installed.

By addressing these issues, you can quickly resolve the error and continue with your development work.

Method 1: Installing Nodemon Globally

The most straightforward way to resolve the “nodemon command not found” error is to install Nodemon globally using npm (Node Package Manager). This ensures that Nodemon is available from any directory in your terminal.

To install Nodemon globally, you can use the following command:

npm install -g nodemon

After running this command, you should see output indicating that Nodemon has been installed successfully.

Output:

+ nodemon@2.0.22
added 1 package from 1 contributor in 0.123s

Installing Nodemon globally allows you to run it from any directory, eliminating the “command not found” error. After installation, try running Nodemon again. If it works, you’re all set! If not, the issue may lie with your system’s PATH variable.

Method 2: Checking and Updating the PATH Variable

If Nodemon is installed but you still encounter the “command not found” error, the issue might be related to your system’s PATH variable. The PATH variable tells your shell where to look for executable files. If the directory where Nodemon is installed isn’t included in your PATH, you’ll face this error.

You can check your current PATH variable by running:

echo $PATH

This command will display a list of directories. If the directory where Nodemon is installed (usually something like /usr/local/bin or /home/your_username/.npm-global/bin) isn’t listed, you’ll need to add it.

To update your PATH variable, follow these steps:

  1. Open your .bashrc or .bash_profile file in a text editor:
nano ~/.bashrc
  1. Add the following line at the end of the file (replace the path with the actual installation path of Nodemon):
export PATH=$PATH:/home/your_username/.npm-global/bin
  1. Save the file and exit the editor. Then, run the following command to apply the changes:
source ~/.bashrc

By updating your PATH variable, you’re informing your system where to find Nodemon. After performing these steps, try running Nodemon again. If everything is set up correctly, the command should work without any issues.

Method 3: Local Installation of Nodemon

If you prefer not to install Nodemon globally, you can also install it locally within your project. This method is particularly useful for ensuring that your project is self-contained and can be easily shared with other developers.

To install Nodemon locally, navigate to your project directory and run:

npm install --save-dev nodemon

This command installs Nodemon as a development dependency in your project. After installation, you can run Nodemon using an npm script. To do this, you’ll need to modify your package.json file. Add a script like the following:

"scripts": {
  "start": "nodemon app.js"
}

Now, you can start your application using:

npm start

Output:

[nodemon] starting `node app.js`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node app.js`

Using Nodemon locally has the added benefit of version control. When you share your project with others, they can install the exact version of Nodemon you used, ensuring consistency across different development environments.

Conclusion

Encountering the “nodemon command not found” error in Linux Bash can be a hassle, but it’s a common issue that can be resolved with a few simple steps. Whether you choose to install Nodemon globally, update your PATH variable, or opt for a local installation, you’ll soon have Nodemon running smoothly. By following the methods outlined in this article, you can focus on what really matters: developing your application with ease and efficiency.

FAQ

  1. What is Nodemon?
    Nodemon is a utility that automatically restarts your Node.js application when file changes are detected.

  2. Why do I get the “nodemon command not found” error?
    This error typically occurs because Nodemon is not installed globally or the installation path is not included in your system’s PATH variable.

  3. How can I check if Nodemon is installed?
    You can check if Nodemon is installed by running the command nodemon -v in your terminal.

  4. Can I use Nodemon without installing it globally?
    Yes, you can install Nodemon locally within your project and run it using npm scripts.

  1. How do I update my PATH variable?
    You can update your PATH variable by editing your .bashrc or .bash_profile file and adding the necessary directory to the PATH.
Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe
Author: Yahya Irmak
Yahya Irmak avatar Yahya Irmak avatar

Yahya Irmak has experience in full stack technologies such as Java, Spring Boot, JavaScript, CSS, HTML.

LinkedIn

Related Article - Bash Error