How to Solve Nodemon Command Not Found
-
Use
npm
to Solve Nodemon Command Not Found -
Use
npx
to Solve Nodemon Command Not Found -
Use
yarn
to Solve Nodemon Command Not Found
By automatically restarting the node application when it detects file changes in the directory, nodemon
is a utility that aids in developing NodeJS-based apps.
Your code and development process need not be altered to use nodemon
. A node wrapper substitute is nodemon
.
When running your script, change the word node
on the command line to nodemon
.
If you have a nodemon command not found
issue when using npm
or NodeJS
on your PC, Mac or Linux, there are different possible ways to solve the problem, especially if nodemon
is present.
This article will discuss how to solve and deal with the nodemon command not found
error.
Use npm
to Solve Nodemon Command Not Found
With npm
, we install useful and functional libraries, packages, and tools to improve our development on the NodeJS platform. Also, nodemon
is available via the package manager.
As with most command not found
error messages, there is a high likelihood that the nodemon
utility hasn’t been installed within your OS.
We need to first check if Node is available using the following command, which outputs the version.
node -v
The expected output is the Node version you have on your system.
v18.4.0
We should also check if we have npm
installed.
npm --version
The expected output is the version of the npm
.
8.12.1
If your version is not the latest, you can use any of the following commands (across all OS).
npm install -g npm@latest
npm update -g
However, for Linux users, you can use the following command sequentially.
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Now that this is out of the way, we can check for nodemon
on your PC to see if it is available.
nodemon -v
You should see any error when you execute the above command.
Regardless of OS, you can use the npm
command to install nodemon
on your PC.
npm install -g nodemon
The above command installs nodemon
globally. However, if you intend to install nodemon
as a development dependency, you can use the following command.
npm install --save-dev nodemon
Afterward, you can check for successful installation by checking the version.
nodemon -v
The expected output of this command is the current version installed.
2.0.19
Also, you can check the help documentation to get started.
nodemon -h
The expected output:
Usage: nodemon [options] [script.js] [args]
Options:
--config file ............ alternate nodemon.json config file to use
-e, --ext ................ extensions to look for, ie. js,pug,hbs.
-x, --exec app ........... execute script with "app", ie. -x "python -v".
If you use a Mac system, you may have issues installing nodemon
directly like this. Therefore, to get rid of the nodemon: command not found
error, you should use the following command, which forces the installation of nodemon
.
sudo npm install -g --force nodemon
If you experience any other issues with EACCES errors, you can check NPM documentation.
Use npx
to Solve Nodemon Command Not Found
The npx
is a package runner and CLI tool that allows us to install and manage dependencies hosted in the npm
registry. It provides an easy way to use CLI tools and other executables hosted on the registry.
Especially for Mac users who have issues with nodemon
installation or usage via npm
and keep getting the command not found
error, npx
provides a good alternative to dealing with nodemon
.
The following command will help run it locally (which means it won’t be available in your system path).
npx nodemon
Afterward, add the below statement within your package.json
file.
"serve": "npx nodemon index.js"
Afterward, use the below command to run nodemon
smoothly.
npm run serve
However, if you are Windows, the first command, npx nodemon
, is enough.
Use yarn
to Solve Nodemon Command Not Found
yarn
is a package manager that is a good alternative to npm
to bring consistency, security, and performance within NodeJS. With yarn
, we can deal with the nodemon command not found
error by installing nodemon
.
The following command will help install nodemon
and eliminate the command not found
error.
yarn global add nodemon
After executing the command, you can check for a successful completion using the following command.
nodemon --version
The output will be the current version installed.
2.0.19
If you don’t have yarn
installed, you can install the npm
using this command.
npm install --global yarn
For Linux, you can make use of the following command.
npm install --global yarn
Afterward, check for successful installation using the below command, which outputs the version.
yarn --version
Olorunfemi is a lover of technology and computers. In addition, I write technology and coding content for developers and hobbyists. When not working, I learn to design, among other things.
LinkedIn