Express can't find my node modules after update to 3.x

Problem

I used to have the following piece of code in my Jade template:

script(src='lib/angular/angular.js')
script(src='/socket.io/socket.io.js')
script(src='js/app.js')
script(src='js/services.js')
script(src='js/controllers.js')
script(src='js/filters.js')
script(src='js/directives.js')

Everything loads except socket.io. After updating to 3.x, It is not loading correctly, gives me 'Uncaught SyntaxError: Unexpected token < ' and loads the following file when inspected in chrome:

<!DOCTYPE html><html ng-app="myApp"><head><meta charset="utf8"><base href="/"><title>Angular Socket.io IM Demo App</title><link rel="stylesheet" href="/css/app.css"></head><body><h1>Angular Socket.io IM Demo App</h1><div ng-controller="AppCtrl"><div class="col"><h3>Messages</h3><div class="overflowable"><p ng-repeat="message in messages" ng-class="{alert: message.user == &quot;chatroom&quot;}">{{message.user}}: {{message.text}}</p></div></div><div class="col"><h3>Users</h3><div class="overflowable"><p ng-repeat="user in users">{{user}}</p></div></div><div class="clr"><form ng-submit="sendMessage()">Message:<input size="60" ng-model="message"><input type="submit" value="Send"></form></div><div class="clr"><h3>Change your name</h3><p>Your current user name is {{name}}</p><form ng-submit="changeName()"><input ng-model="newName"><input type="submit" value="Change Name"></form></div></div><script src="lib/angular/angular.js"></script><script src="/socket.io/socket.io.js"></script><script src="js/app.js"></script><script src="js/services.js"></script><script src="js/controllers.js"></script><script src="js/filters.js"></script><script src="js/directives.js"></script></body></html>

Which is just the compiled index page...

I'm new to Express and can't figure out how to get it to recognize my node_modules now. Any help is appreciated.

server.js

/**
 * Module dependencies.
 */

var express = require('express'),
    app = express(),
    path = require('path'),
    routes = require('./app/routes'),
    http = require('http'),
    socket = require('./app/routes/socket.js'),
    server = http.createServer(app);

// Hook Socket.io into Express
var io = require('socket.io').listen(server);

// Configuration

app.configure(function(){
  app.set('views', __dirname + '/app/views');
  app.set('view engine', 'jade');
  app.set('view options', {
    layout: false
  });
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.static(__dirname + '/public'));
  app.use(app.router);
});

app.configure('development', function(){
  app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

app.configure('production', function(){
  app.use(express.errorHandler());
});

// Routes

app.get('/', routes.index);
app.get('/partials/:name', routes.partials);

// redirect all others to the index (HTML5 history)
app.get('*', routes.index);

// Socket.io Communication

io.sockets.on('connection', socket);

// Start server

app.listen(3000);
Problem courtesy of: Neil

Solution

Change app.listen(3000); to server.listen(3000);. The express/http/socket.io integration boilerplate is tricky and easy to copypasta without paying attention.

Solution courtesy of: Peter Lyons

Discussion

There is currently no discussion for this recipe.

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