For a while I searched Google to find the answer to this question, but I still cannot find this question in my code. I am trying to make my first Socket.io application, which simply displays a message to the console when the user connects.
Here is the error I get from Node.js:

And here is my source code:
var port = process.argv[2];
var express = require('express');
var app = express();
var path = require('path');
app.get('/', function(req, res) {
res.render('index.ejs');
})
.use(app.static(path.join(__dirname, '/public')));
var io = require('socket.io')(app.listen(port));
io.on('connection', function(socket) {
console.log('Someone connected');
});
console.log('Listening on port ' + port);
Run codeHide resultThanks in advance for your advice!
source
share