title: socket.io: Failed to load resource
body: <p>I'm trying to getting started with socket.io and node.js.</p>
  
  <p>Following the first example on the socket.io's site I'm getting the following error in the browser's console:</p>
  
  <pre><code>Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3001/socket.io/socket.io.js
  Uncaught ReferenceError: io is not defined 
  </code></pre>
  
  <p>This is my server.js</p>
  
  <pre><code>var app = require('express').createServer()
    , io = require('socket.io').listen(app);
  
  app.listen(3001);
  
  app.get('/', function (req, res) {
    res.sendfile(__dirname + '/index.html');
  });
  
  io.sockets.on('connection', function (socket) {
    socket.emit('news', { hello: 'world' });
    socket.on('my other event', function (data) {
      console.log(data);
    });
  });
  </code></pre>
  
  <p>And this is my index.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;meta charset="UTF-8" /&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt;
  &lt;script&gt;
    var socket = io.connect('http://localhost');
    socket.on('news', function (data) {
      console.log(data);
      socket.emit('my other event', { my: 'data' });
    });
  &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I've already installed socket.io..</p>