I am following this tutorials to experiment Exress 4 router.
But when I type: node server.js, I got the fllowing error:
> events.js:72
> throw er; // Unhandled 'error' event
> ^ Error: listen EADDRINUSE
> at errnoException (net.js:901:11)
> at Server._listen2 (net.js:1039:14)
> at listen (net.js:1061:10)
> at Server.listen (net.js:1135:5)
> at Function.app.listen (/Users/tom/Documents/Projects/express4router/node_modules/express/lib/application.js:531:24)
> at Object.<anonymous> (/Users/tom/Documents/Projects/express4router/server.js:22:5)
> at Module._compile (module.js:456:26)
> at Object.Module._extensions..js (module.js:474:10)
> at Module.load (module.js:356:32)
> at Function.Module._load (module.js:312:12)
It looks like node app.js doesn't work in express4. How do I run this simple script in express 4?
var express = require('express');
var app = express();
var port = process.env.PORT || 8080;
app.get('/sample', function(req, res) {
res.send('this is a sample!');
});
app.listen(port);
console.log('Magic happens on port ' + port);