Getting started with Express - Error: Cannot find module './routes'
- by Enrico Tuttobene
I am just getting started in the world of Node.JS, and I tried using the command line "express" command to install a basic application (with jade support)
Now, I was playing around with it a bit to see how it works and I am coming across a strange error:
In the /routes directory there is a file called index which contains
exports.index = function(req, res){ res.render('index', { title: "Express" }); };
that, as you all know, renders the index page.
Well, all I did was renaming that file from index.js to router.js, so that I can easily refer to it as I would like to have more than just an index page.
The renaming doesn't work, I get the error
Error: Cannot find module './routes'
Which is weird, as I though that
var express = require('express'),
routes = require('./routes');
would require ALL the files in the directory.
There must be something small there I'm missing, and please bare with me as I am pretty new to this.
Thanks in advance.