Note that there are some explanatory texts on larger screens.

plurals
  1. POSocket.io not being served by Node.js server
    primarykey
    data
    text
    <p>As I understood it, from <a href="http://socket.io/#how-to-use">http://socket.io/#how-to-use</a>, node.js automatically serves the socket.io file on the server.</p> <p>I have installed socket.io with <code>npm install socket.io</code> and I can see that it resides in <code>node_modules</code> one level above the server root. </p> <p>server.js:</p> <pre><code> var static = require('./plugins/node-static'); var socketIO = require('socket.io'); var clientFiles = new static.Server('./client'); var http = require('http'); httpServer = http.createServer(function (request, response) { request.addListener('end', function () { clientFiles.serve(request, response); }); }).listen(8253); var webSocket = socketIO.listen(httpServer); webSocket.on('connection', function(client) { ..... </code></pre> <p>index.html:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Chat&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { var webSocket = new io.Socket('localhost', { port: 8253 }); webSocket.connect(); ....... </code></pre> <p>Starting the server works fine, but when opening index.html, I receive the following error:</p> <pre><code>GET http://localhost:8253/socket.io/socket.io.js 404 (Not Found) Uncaught ReferenceError: io is not defined :8253/:25 </code></pre> <p>Ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload