I began learning Node.js today and I\'m a little stuck.
Following this example, I get the following error when I try executing the js file:
Warning: expr
There was a change to how you initialize express
apps between versions 2 and 3. This example is based on version 2 but it looks like you've installed version 3. You just need to change a couple of lines to set up socket.io
correctly. Change these lines:
var app = require('express').createServer(),
io = require('socket.io').listen(app),
scores = {};
// listen for new web clients:
app.listen(8080);
to this:
var express = require('express'),
app = express()
, http = require('http')
, server = http.createServer(app)
, io = require('socket.io').listen(server);
// listen for new web clients:
server.listen(8080);
Simplified to three lines of code that would be:
var server = require('http').createServer(require('express')()),
io = require('socket.io').listen(server);
server.listen(8080);