Error: Cannot find module, Nodemon crashes


I am new with NodeJS and Express. I heard about nodemon and was trying to run it. But got an error. I tried solution from github, stack but nothing seems to work.

When I run node app.js it works properly and even localhost:3000 responds to it.

But specifically nodemon dont seem to work. I have installed it globally.

And please believe me when I say that I visited all the stackoverflow pages that has solution for this issue. But none seems to work. I installed Nodejs again. I have reinstalled node_modules many time.
And tried to change scripts{} in package.json as said on those pages.

  "name": "prac-mysql",
  "version": "1.0.0",
  "description": "Connecting MySQL NODEjs",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.1",
    "faker": "^4.1.0",
    "mysql": "^2.18.1",
    "nodemon": "^2.0.3"

Above is the initial code as how it was. Please help me. Thank you so much.

(I am using it on windows system)

This is the error I get


From your screenshot I can see that you’re using minGW. On their official website it is stated:

MinGW may have problems with paths containing spaces, and if not,
usually other programs used with MinGW will experience problems with
such paths. Thus, we strongly recommend that you do not install MinGW
in any location with spaces in the path name reference. You should
avoid installing into any directory or subdirectory having names like
“Program Files” or “My Documents”, etc.

So probably this is not an issue with nodemon itself but with the underlying resolving of the path. Try using different directory names without spaces or executing nodemon from cmd/powershell.


The problem is that you’re running nodemon without specifying any file and it will try to look for the main-file that you set in your package.json. Since you’ve set it to index.js and such file does not exist, the command fails. Changing main to app.js in your package.json should fix the issue.

Answered By – eol

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published