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.
- Nodemon is not installed.
- Nodemon is available in a different path.
- 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:
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 -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.
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 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:
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!!