title: My routes index.js file gives error (Module not found)
body: <p>The error says "Cannot find module './routes/index'" but clearly it is in that folder (even when static is set to that folder)</p>
  
  <p>Here is the error:</p>
  
  <pre><code>root@ip*censored*:/home/ubuntu/*censored*# module.js:471
      throw err;
      ^
  
  Error: Cannot find module './routes/index'
      at Function.Module._resolveFilename (module.js:469:15)
      at Function.Module._load (module.js:417:25)
      at Module.require (module.js:497:17)
      at require (internal/module.js:20:19)
      at Object.&lt;anonymous&gt; (/home/ubuntu/*censored*/routes/index.js:7:14)
      at Module._compile (module.js:570:32)
      at Object.Module._extensions..js (module.js:579:10)
      at Module.load (module.js:487:32)
      at tryModuleLoad (module.js:446:12)
      at Function.Module._load (module.js:438:3)
  </code></pre>
  
  <p>Here is what my directory looks like:</p>
  
  <pre><code>-bin
  -forbiddenDirectory
  -Node_modules
  -public
  -routes
  -----index.js
  -----users.js
  -views
  app.js
  main.js
  bundle.js
  package.json
  </code></pre>
  
  <p>This is in my app.js:</p>
  
  <pre><code>var routes = require("./routes/index");
  app.use('/', routes);
  </code></pre>
  
  <p>This is in my index.js:</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  var app = express();
  var aws = require('aws-sdk');
  var request = require('request');
  var cheerio = require('cheerio');
  var routes = require('./routes/index');
  var fs = require('fs');
  var url = "http://news.google.com";
  var ep = new aws.Endpoint('censored.us-west-1.censored.com');
  var db = new aws.DynamoDB.DocumentClient({      // Dynamo database constructor
      "apiVersion": '2012-08-10',
      "region": 'us-west-1',
      "endpoint": ep,
      "accessKeyId": 'censored',
      "secretAccessKey": '+censored/censored'
  });
  var dateObj = new Date();
  var dbTimeStamp = dateObj.toLocaleString();
  
  // middleware that is specific to this router
  router.use(function timeLog (req, res, next) {
    next();
  });
  
  
  /* GET home page. */
  router.get('/', function(req, res, next) {
    res.render('index');
  });
  
  //module.exports = router;
  module.exports = function(req,res,next) { res.render('index')}
  </code></pre>
  
  <p>So it is clearly in the routes folder but it doesn't read it for some reason. I tried everything... I tried changing ./routes/index to ./routes/index.js,  to ./routes/, then ./routes, then /routes, then tried routes/index/, then did ../routes/index same with .js afterwards. I give up and need your guys help.
  Thank you.</p>