title: Function.Module._resolveFilename (module.js:547:15) at Function.Module._load
body: <p>I am getting following error</p>
  
  <blockquote>
    <p>Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (C:\Users\u8ser\Desktop\Todo\server.js:25:1) at Module._compile (module.js:652:30) [nodemon] app crashed - waiting for file changes before starting</p>
  </blockquote>
  
  <p>PFB source code for your ref.</p>
  
  <p>My server.js file</p>
  
  <pre><code>var express = require("express");
  var app = express();
  var mongoose = require("mongoose");
  var methodOverride = require("method-override");
  var port = process.env.PORT || 8080;
  var database = require('./config/database');
    var morgan = require("morgan");
  var bodyParser = require("body-parser");
  
  mongoose.connect('mongodb://localhost:27017', function(err){
      if (err){
          console.log(err);
      }else{
          console.log("Connected to DB");
      }
  });
  
  app.use(express.static(__dirname + '/public'));
  app.use(morgan('dev'));
  app.use(bodyParser.urlencoded({'extended':'true'}));
  app.use(bodyParser.json());
  app.use(bodyParser.json({ type : 'application/vnd.api+json'}));
  app.use(methodOverride());
  
  require('./models/routes')(app);
  
  app.listen(port);
  console.log("App listining to port" + port);
  </code></pre>
  
  <p>My routes.js file</p>
  
  <pre><code>var Todo = require('./models/todo');
  
  module.exports = function(app){
  
      app.get('/api/todos', function(req, res){
      Todo.find(function(err, todos){
          if (err)
          res.send(err)
  
          res.send(todos)
  
        });
      });
  
   // create todo and send back all todos after creation
  
  app.post('/api/todos', function(req, res){
  
      // create a todo, information comes from AJAX request from Angular
  
      Todo.create({
          text : req.body.text,
          done : false
      }, function(err, todo) {
          if (err)
             res.send(err);
  
         //get and return all the todos after you create another
  
         Todo.find(function(err, todos){
             if (err)
                 res.send(err)
              res.json(todos);
         });
      });
  
  });
  
  //delete a todo
  app.delete('/api/todos/:todo_id', function(req, res){
      Todo.remove({
         _id : req.params.todo_id
      }, function(err, todo){
          if (err)
          res.send(err);
  
          //get and return all the todos after you create another
          Todo.find(function(err, todos){
              if (err)
              res.send(err)
              res.json(todos);
          });
      });
  });
  
  
  // server.js 
  // application -------------------------------------------------------------
  app.get('*', function(req, res) {
      res.sendfile('./public/index.html'); // load the single view file (angular will handle the page changes on the front-end)
  });
  
  };
  </code></pre>
  
  <p>Kindly visit this <a href="https://github.com/roshantak44/todo" rel="nofollow noreferrer">github link</a> for full source code.</p>