title: socket.io type error (http) object is not a function
body: <p>I am learning to use socket.io from its web website <a href="http://socket.io/get-started/chat/" rel="nofollow">Socket.IO</a>. Everything went fine, but after I add the 3rd line <code>var io=require('socket.io')(http);</code> I got the error when trying to run the server:</p>
  
  <pre><code>C:\Users\user\chat-example\index.js:3
  var io = require('socket.io')(http);
                               ^
  TypeError: object is not a function
      at Object.&lt;anonymous&gt; (C:\Users\user\chat-example\index.js:3:30)
      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)
      at Function.Module.runMain (module.js:497:10)
      at startup (node.js:119:16)
      at node.js:929:3
  </code></pre>
  
  <p>This is the code as in the <a href="http://socket.io/get-started/chat/" rel="nofollow">Socket.IO</a></p>
  
  <pre><code>var app = require('express')();
  var http = require('http').Server(app);
  var io = require('socket.io')(http);
  
  app.get('/', function(req, res){
    res.sendfile('index.html');
  });
  
  io.on('connection', function(socket){
    console.log('a user connected');
  });
  
  http.listen(3000, function(){
    console.log('listening on *:3000');
  });
  </code></pre>
  
  <p>What's wrong? This is my first time learning nodejs and socket.io. So I would really appreciate if you could kindly help me understand and solve the problem. Thank you.</p>