I believe this will be hard to trouble shoot without me giving more information.
But, I have the following set up in a small modular setup:
//index.js aka the server
...
// set views path, template engine and default layout
app.set('views', './app/views');
app.set('view engine', 'jade');
var routes = require('./app/routes')
....
//routes.js
var router = require('express').Router();
// Include the controllers
var home = require('../controllers/home');
// GET home page
router.get('/', home.home);
router.get('/home', home.home);
module.exports = router;
//controllers/home.js
module.exports = {
home: function (req, res) {
res.render('index', {
title: 'Home Page'
});
}
};
Then navigating to / returns:
Cannot GET /
I started node as of 2 hours ago... so... I suck basically :)
So I think your problem is you never connect your index.js app express instance to the router you define in routes.js. In index.js, append a line after you require routes:
app.use(routes);
Now the main express instance will include the routes defined in routes.js when routing requests through the middleware stack and you should be up and running.