I’m following this youtube tutorial on MERN.
Video link:
https://www.youtube.com/watch?v=xKs2IZZya7c&ab_channel=CodingWithDawid
Application github link:
https://github.com/dejwid/mern-blog
At minute 45:00 of the video, he mentions installing nodemon without
go into too much detail. I installed this but nodemon is not working. When I type at the command prompt:
nodemon index.js
There, an error message appears:
nodemon : The term ‘nodemon’ is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling
of the name or, if a path was included, verify that the path is
correct and try again.
On line:1 character:1
+ nodemon index.js
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (nodemon:String) [], CommandNotFoundEx
conception
+ FullyQualifiedErrorId : CommandNotFoundException
nodemon is installed globally, as you can see in my package.json
package.json:
{
"dependencies": {
"express": "^4.18.2",
"g": "^2.0.1",
"react-router-dom": "^6.10.0"
},
"devDependencies": {
"nodemon": "^2.0.22"
}
}
3
Answers
You can add a command in the
scripts
object as key-namestart
in the package.json like below and you can run your application usingnpm start
.the solution is to run as:
or to install nodemon globally so it’s available as a cli command:
ref: https://www.npmjs.com/package/nodemon & https://nodemon.io/
There are 2 issues:-
You have NOT installed nodemon globally. Brother you are saying that nodemon is installed globally and then you are saying that it is in package.json file. Please note :- Globally installed nodemon is not found in the
package.json
file.You have installed a local version of nodemon. If you see
nodemon
in yourpackage.json file
, it means you have installed it locally. For locally installed nodemon, writingnodemon index.js
directly in the terminal does NOT work.The solutions are the following:-
To install nodemon globally, you run
npm install --global nodemon
and to verify installation you see it in the list of globally installed modules by runningnpm list --global
. Now you can directly runnodemon index.js
in the terminal command prompt.To install nodemon locally, you run
npm install nodemon
ORnpm install -D nodemon
. Now you cannot directly run nodemon in the terminal. You need to create a script in the package.json using nodemon for example"[script name]": "nodemon index.js"
. Now in the terminal, you will runnpm run [script name]
to run nodemon.