Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodemon app crashed : Error code- MODULE_NOT_FOUND, requirestack: [ ]

When I am running nodemon run start it is giving me the following error I am running this on macos. Not sure if that matters or not. ERROR

node:internal/modules/cjs/loader:926
  throw err;
  ^

Error: Cannot find module '/Users/jarvis/Documents/Backend/mongoTelusko/run'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:923:15)
    at Function.Module._load (node:internal/modules/cjs/loader:768:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
[nodemon] app crashed - waiting for file changes before starting...

This is my app.js file

const express = require('express')
const mongoose = require('mongoose')
const url = 'mongodb://localhost/AlienDBex'

    enter code here

const app = express()

mongoose.connect(url, {useNewUrlParser: true})
const con = mongoose.connection

con.on('open', function(){
    console.log('Connected...')
})

This is my package.json file

{
  "name": "mongotelusko",
  "version": "1.0.0",
  "main": "app.js",
  "scripts": {
    "start": "nodemon app.js"
  },
  "author": "malay",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.1",
    "mongodb": "^3.6.5",
    "mongoose": "^5.12.2"
  },
  "devDependencies": {
    "nodemon": "^2.0.7"
  },
  "description": ""
}
like image 307
Malay Avatar asked Oct 23 '25 00:10

Malay


1 Answers

"scripts": {
    "start": "nodemon app.js"
  }, 

Since you have specified "start" script in package.json, npm start command automatically calls nodemon app.js However, you can also run the nodemon app.js manually which also has the same effect.

Wrong: nodemon run start
Correct: nodemon app.js or npm start

like image 189
BryanRonnie Avatar answered Oct 25 '25 14:10

BryanRonnie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!