Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't find socket.io.js
    text
    copied!<p>I'm making a web-app that makes use of nodejs, mongodb, socket.io, express and mongoose. <br/> I can start my server and correctly get the wanted html file in my browser when browsing to my localhost.<br/> The problem I have is getting my socket.io to work. On my server side everything works fine : I get " info - socket.io started " in my terminal.</p> <p>But when surfing to my browser I get this in my browser console <br /><br /></p> <pre><code> Failed to load resource: the server responded with a status of 404 (Not Found) Uncaught ReferenceError: io is not defined </code></pre> <p>This is how i connect to socket.io.js</p> <pre><code> &lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt; </code></pre> <p>and my map structure looks like this:</p> <pre><code> map -app.js -public --index.html -node_modules --socket.io --mongodb --express --jade --mongoose </code></pre> <p>Does anyone knows what the mistake is I've made?</p> <p>(it's actually the same problem as here: <a href="https://stackoverflow.com/questions/10563080/node-js-socket-io-js-not-found-or-io-not-defined">Node.js socket.io.js not found or io not defined</a> )</p> <p>Thanks in advance!</p> <p><strong>EDIT:</strong> My code on the server side is this:</p> <pre><code> var app= require('express').createServer(); var io = require('socket.io').listen(app); var mongoose = require('mongoose'); var db = mongoose.connect('mongodb://localhost/db'); app.listen(3030); console.log("server started"); app.get('/',function(req,res){ res.sendfile(__dirname + '/public/index.html'); }); io.sockets.on('connection',function(socket){ console.log("connection made"); }); </code></pre> <p>The first log, gets logged in the terminal ("server started"), but the second one ("connection made") doesn't get logged. So the connection isn't made. I thought that was because of the wrong "set up" in my client side.</p>
 

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