title: nodeJS cannot find module in the same folder
body: <p>I have a simple node application where i want to include a module named dishRouter.
  The directory structure is like this :-
  <a href="https://i.stack.imgur.com/CqvxU.png" rel="nofollow noreferrer">Structure</a><br>
  Dishes/index.js exports the dishRouter that i use in my app.js by<br>
      <code>var dishRouter = require('/dishRouter')</code><br>
  When i run app.js using node app, it says : <a href="https://i.stack.imgur.com/5OR4T.png" rel="nofollow noreferrer">The Error</a><br>
  i tried to print __dirname and it gives<br>
      <em>"C:\Users\Kush\Desktop\NodeExamples\Express-example\Assignmnet1"</em><br>
  I do not understand why node cannot find the module 'dishRouter' while it is in the same directory.
  Any help is appreciated, and sorry for the messed up structure of questions.
  Code in Dishes/index.js : </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var DishRouter = require('express').Router();
  var fs = require('fs');
  var bodyparser= require('body-parser');
  DishRouter.use(bodyparser.json());
  DishRouter.all('/', function(req,res,next){
    res.writeHead(200,{'Content-Type': 'text/plain'});
    next();
  });
  DishRouter.get('/',function(req,res,next){
    res.end('Will send the dish list to you!');
  });
  DishRouter.post('/',function(req,res,next){
    res.end('will add the Dish named : '+req.body.name+' and the Description : '+req.body.description);
  });
  DishRouter.delete('/',function(req,res,next){
    res.end('will DELETE all dishes');
  });
  DishRouter.get('/:dishId',function(req,res,next){
    res.end('Will send the dish with name : '+req.params.dishId+' to you!');
  });
  DishRouter.put('/:dishId',function(req,res,next){
    res.end('Update the dish named : '+req.params.dishId+', Details to : '+req.body.description);
  });
  DishRouter.delete('/:dishId',function(req,res,next){
    res.end('will DELETE dish : '+req.params.dishId);
  });
  module.exports = dishRouter;</code></pre>
  </div>
  </div>
  <br>
  Code in routes/index.js :  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var express = require('express');
  var fs = require('fs');
  var DishRouter = require('./dishRouter');
  
  var routes= express.Router();
  var util = require('util');
  routes.get('/', (req, res, next) =&gt; {
    console.log(util.inspect(req));
    res.writeHead(200,{'Content-Type': 'text/plain'});
    next();
  });
  routes.delete('/',(req,res)=&gt; {
    res.sendStatus(404);
  });
  routes.use('/dishes', DishRouter);
  
  module.exports = routes;</code></pre>
  </div>
  </div>
  <br>
  code in Assignment1/app.js : </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var express = require('express');
  var routes = require('./routes');
  var hostname = 'localhost';
  var port = 3000;
  var app =express();
  
  app.use(express.static(__dirname + '/routes'));
  app.use('/', routes);
  app.listen(port,hostname,function(){
    console.log('Server running on port '+port);
  });</code></pre>
  </div>
  </div>
    </p>