nodemon is an utility that was built to improve Node.js developing workflow. Normally, every time you modify a piece of code, you would have to re-run
node app.js for the changes to take effect. Now nodemon will automatically do that for you, saving you a little bit more time to focus on your actual code.
nodemon does not require any additional changes to your code or method of development. nodemon is a replacement wrapper for
node. You have to replace
nodemon every time you want your code to be reloaded automatically once changed.
In this article, we will show you common causes of “nodemon: command not found” error as well as how to fix it for each scenario.
Also see: “Can’t set headers after they are sent to the client” error in Express.js – possible solutions
“nodemon: command not found” causes
There are several things that can trigger the “nodemon command not found” error:
- nodemon is not installed: Beginners often assume that nodemon is included as a part of standard Node.js installation. There are other cases that they don’t know
- nodemon is installed in a different environment, not the one you’re using: Most operating systems look for executables and binaries in a specific set of places. The list of all those places is stored in an environment variable, often named
- nodemon is installed locally instead of globally: One software package that depends on another expects its companion to be in a specific version.
- The current user does not have permission to access nodemon executable
Make sure you’ve installed nodemon globally
Installing locally makes nodemon available to the current project (where it stores all of the node modules in
node_modules). This is usually only good for using a module like so
var module = require('module');
If you’ve installed nodemon this way, it will not be available as a command that the shell can resolve. Instead, you have to install it globally by running
npm install -g module , at this very moment, npm will install the package in a place included in the PATH variable, then the shell (terminal) would be able to understand the command. The flag
So, to sum up, just run the two command below to sequentially uninstall the re-install nodemon globally.
npm uninstall nodemon npm install -g nodemon
In rare cases where the current user does not have permission to access nodemon executable path, you have to prefix the commands with
sudo to run it as root.
sudo npm uninstall nodemon sudo npm install -g nodemon
Symlink nodemon to /usr/local/bin
Most of the time, when you’re installing a package using npm, the binary of that package will be placed in a folder which was added to PATH. However, this process may sometime be stuck somewhere in the middle, making things hard to debug.
In this case, you can try manually creating a symlink in
/usr/local/bin, which is a default location the shell searches for binaries, that points to the actual nodemon binary in node_modules directory. Run the following command in a terminal to do that.
sudo ln -s /usr/local/lib/node_modules/nodemon/bin/nodemon.js /usr/local/bin/nodemon
nodemon installed as development package
If you followed instructions from
nodemon Github repository, you may have installed nodemon as a development dependency using
Since this is a local installation, nodemon will not be available in your system path or you can’t use it directly from the command line. Instead, the local installation of nodemon can be run by calling it from within an npm script (such as
npm start) or using
In this case, there is a few handy command to further inspect the situation. First, you can list out all globally installed packages to see if nodemon is really in the list or not by running.
npm list -g --depth=0Code language: PHP (php)
If you will not find
nodemon, – install it with flag
--save-dev. Don’t install
nodemon with flag
nodemon uses only for
npm install --save-dev nodemon
1 thought on “How to fix “nodemon: command not found””
It worked for me thanks!! much useful post