Search code examples
node.jsmongodbexpressnodemon

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


Solution

  • 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",