For people that has this problem when using node.js & express app, here I show you way to solve it.

The error that you will see upon start the node.js:

Warning: express.createServer() is deprecated, express
applications no longer inherit from http.Server,
please use:

  var express = require(“express”);
  var app = express();

Socket.IO’s `listen()` method expects an `http.Server` instance
as its first parameter. Are you migrating from Express 2.x to 3.x?
If so, check out the “Socket.IO compatibility” section at:
https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x
   info  – socket.io started

The solution is to change this line:

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);

Try to start again. Problem solve. 🙂

By zam

Any Comments?

This site uses Akismet to reduce spam. Learn how your comment data is processed.