socket.io can't get it to work

Problem

EDIT 1:

Ok, problem with the server solved. This is the full server code integrated into my project.

var http =              require('http');
var express =           require('express');
var requestHandler =    require(__dirname + '/app_modules/request-handler.js');
var app =               express();

app.configure(function(){
    app.use(express.static(__dirname + '/html'));
    app.use(express.bodyParser());
});

var httpServer = http.createServer(app);
httpServer.listen(80);

var io = require('socket.io').listen(httpServer);

io.on('connection', function(socket){
    socket.on('event', function(data){

    });
    socket.on('disconnect', function(){

    });
});

The next issue is including the source .js in my static html page. This throws an error:

<script src="/socket.io/socket.io"></script>

Resource interpreted as Script but transferred with MIME type text/plain: "http://localhost/socket.io/socket.io". localhost/:206
Uncaught SyntaxError: Unexpected identifier socket.io:1
Uncaught ReferenceError: io is not defined 

ORIGINAL PROBLEM:

I'm trying to get this sucker working on a test server. This is 1:1, straight from the socket.io docs on github.

var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);

io.on('connection', function(socket){
    socket.on('event', function(data){

    });
    socket.on('disconnect', function(){

    });
});

server.listen(3000);

Here is what I'm getting:

[INFO] 19:37:40 Restarting
[ERROR] 19:37:40 TypeError
TypeError: object is not a function
    at Object.<anonymous> (/Users/me/work/github/node-forever-gui/server/socket_test.js:3:30)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Object..js (/usr/local/lib/node_modules/node-dev/lib/hook.js:52:17)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/node-dev/lib/wrap.js:47:1)
    at Module._compile (module.js:456:26)

All modules are installed through npm. Please help me figure this out!

Problem courtesy of: Nikolay Dyankov

Solution

The is exactly what is stated, io is not a function and you can't pass a HTTP object to it. Use the listen method instead to attach Socket.IO to a HTTP instance.

var io = require('socket.io').listen(server);

For your second error, the file is a script, and has an extension. Add the .js to the reference.

<script src="/socket.io/socket.io.js"></script>
Solution courtesy of: hexacyanide

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.