Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodemon index.js

I'm brand new to nodemon. After following the steps on this video at 12:01 https://www.youtube.com/watch?v=eB9Fq9I5ocs , I get the following errors when trying to run my app using nodemon: enter image description here

HERE IS THE APP.JS file:

var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var mongoose = require('mongoose');

// Connect to Mongoose
mongoose.connect('mongodb://localhost/ChatbotService')
var db = mongoose.connection;

app.get('/', function(req, res){
    res.send('Hola4');
});

app.listen(8601);
console.log('Running on port 8601...');

HERE IS THE PACKAGE.JSON FILE:

{
  "name": "chatbot",
  "version": "1.0.0",
  "description": "chatbot app",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "express": "*",
    "body-parser": "*",
    "mongoose": "*"
  },
  "author": "Chris",
  "license": "ISC",
  "devDependencies": {
    "nodemon": "^1.11.0"
  }
}

What do I need to do to get nodemon to find the index.js module?

Thanks

like image 506
Chris Avatar asked Nov 29 '25 11:11

Chris


1 Answers

The problem is your main file is called app.js but in the package.json file your main file is index.js. You need to change it, so nodemon knows what file to look for:

"main": "app.js",
like image 159
RamiroP Avatar answered Dec 01 '25 23:12

RamiroP



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!