JavaScript

Nodemon Command Not Found

“Nodemon is a fantastic utility for Node.js developers. It allows developers to focus on writing code without worrying about refreshing the changes. It works by restarting the application any time the files and directories in the application are modified.

This makes the developer workflow much easier and smooth. Yes, you’ve got enough bugs to worry about.

However, when you are getting started with Node.js development, you may encounter the “Nodemon command not found” error. And in this tutorial, we aim to help you understand why this error occurs and give you a quick and easy method to fix it.”

Let’s get started.

“Nodemon Command Not Found” Error – Cause

The following are some of the causes of the “Nodemon command not found” error.

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

The above are some of the major causes of the “Nodemon command not found” error.

Let us discuss each cause of the error and its corresponding possible fix.

Nodemon is Not Installed

As you are getting started, you might think that Nodemon is part of the Node.JS package. However, this is not the case; although it does provide some highly needed features by Node.js developers, it needs to be installed manually.

Hence, even if you have Node.js installed, it does not mean Nodemon is as well.

To resolve this issue, you can simply install Nodemon as shown in the commands below:

$ sudo nmp install -g nodemon

The command uses the Node Package Manager to download and install the Nodemon utility on a global level.

If you had previously installed Nodemon without the -g flag, you can re-install it by running the command:

$ sudo npm uninstall nodemon
$ sudo npm uninstall -g nodemon

And with that, you should have the Nodemon command available in your system.

Nodemon Utility is Installed on a Different Path

Unix systems have a set of directories that will be checked when you invoke a command from the terminal. Popular directories include /bin, /usr/bin /sbin, /usr/local/bin, /usr/sbin, etc.

Therefore, if Nodemon is installed in a different directory that is not available in the system’s path environment variable, the command will fail.

By default, Nodemon is installed in the /usr/local/bin/Nodemon directory. If Nodemon is in a different location, you can create a symbolic link to the target directory.

sudo ln -s /target/ /where/nodejs/is/installed

Ensure that the target directory is part of the path.

Nodemon is Not Installed Globally

Nodemon needs to be installed on a global level so that you can import it to any project. Therefore, if you installed it without the -g flag, it will only be accessible in that project.

You can resolve this by uninstalling it and installing it as a global package:

$ sudo nmp uninstall nodemon
$ sudo nmp install -g nodemon

Ensure to run the command with root privileges to avoid any errors that may arise from insufficient permissions.

You can also fix incorrect permission by running the command:

$ sudo chown -R $USER:$(id -gn $USER) /Users/username/.config

Finally, you can verify that nodemon is working by checking the version:

Congratulations, you now have the nodemon command available.

Conclusion

In this tutorial, we covered the various causes of the “nodemon command not found” error and how to fix it.

Thanks for reading!!

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list