skip to Main Content

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


  1. You can add a command in the scripts object as key-name start in the package.json like below and you can run your application using npm start.

    "scripts": {
        "start": "nodemon index.js",
      }
    
    Login or Signup to reply.
  2. the solution is to run as:

    npx nodemon index.js
    

    or to install nodemon globally so it’s available as a cli command:

    npm install -g nodemon
    

    ref: https://www.npmjs.com/package/nodemon & https://nodemon.io/

    Login or Signup to reply.
  3. There are 2 issues:-

    1. 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.

    2. You have installed a local version of nodemon. If you see nodemon in your package.json file, it means you have installed it locally. For locally installed nodemon, writing nodemon index.js directly in the terminal does NOT work.

    The solutions are the following:-

    1. 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 running npm list --global. Now you can directly run nodemon index.js in the terminal command prompt.

    2. To install nodemon locally, you run npm install nodemon OR npm 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 run npm run [script name] to run nodemon.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search