express.js not showing console.log message when routing

First, you need to check the file structure. If index.js and things.js are in the same directory then you need to change the require function to var things = require('./things.js');

Next, verify that you are looking in the correct place, the console.log() message will appear in the terminal window where you loaded the express server, not in the console in your web browser.


The problem is that Express passes requests to both middleware and route handlers in order of their declaration. If any of them are able to handle the request (by sending back a response), any other matching middleware or route handlers that got declared later won't get called.

That's what's happening in your situation, where your middleware is declared after the route handlers.

Try moving your middleware to the front:

app.use('/',function(req, res, next){
   console.log("A new request received at " + Date.now());
   next();
});

app.get('/', function(req, res) {
   res.send('id: ' + req.params.id + ' and name: ' + req.params.name);
});

var things = require('./things/things.js');

app.use('/things', things);