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": ""
}
"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