title: Node js with express and socket.io - cannot find socket.io.js
body: <p>I was working on a node js application with socket.io. I looked at some of the answers on SO but they could not help me with my problem. The error I am getting is </p>
  
  <pre><code>Failed to load resource: the server responded with a status of 404 (Not Found)
  localhost/:10 Uncaught ReferenceError: io is not defined
  </code></pre>
  
  <p>Here is my directory structure:</p>
  
  <pre><code>Judgement
  |----node_modules
  |----|----express
  |----|----socket.io
  |----public
  |----|----css
  |----|----|----judgementMain.css
  |----|----js
  |----|----|----form.js
  |----|----index.html
  |----server.js
  |----package.json
  </code></pre>
  
  <p>In my index.html page
  I have the following link to socket.io.js</p>
  
  <pre><code>  &lt;script type="text/javascript" src="socket.io/socket.io.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
        var socket = io();
    &lt;/script&gt;
  
    &lt;script type="text/javascript" src="js/form.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>The contents of server.js are as follows</p>
  
  <pre><code>var express = require('express');
  var app = express();
  var path = require('path');
  
  // Define the port to run on
  app.set('port', 3000);
  app.use(express.static(path.join(__dirname, 'public')));
  
  // Listen for requests
  var server = app.listen(app.get('port'), function() {
      var port = server.address().port;
      console.log('Magic happens on port ' + port);
  });
  
  var http = require('http').Server(app);
  var io = require('socket.io')(http);
  
  io.on('connection', function (socket) {
      console.log('A user connected');
      socket.on('disconnect', function() {
          console.log('A user disconnected');
      });
  });
  </code></pre>
  
  <p>Can someone explain what I am doing wrong? I only just started with node js and express and socket.io, so any help is appreciated.</p>
  
  <p>Thanks</p>