1

I've been pulling out my hair trying to figure this problem out. I have a node.js app that works fine in windows. I zipped everything up and put it on my linux box (Ubuntu 12) and installed all of the libraries through npm, and yet I still get a 404 message saying my socket.io.js file cannot be found. I've tried various solutions such as linked to the cdn.socket.io script but that just throws a "require not found" error. My code in my html is as follows:

<script src="/socket.io/socket.io.js"></script>

I've even tried <script src="localhost:4000/socket.io/socket.io.js"></script>

and here is my server side:

var express = require('express');
var app = express.createServer();
var io = require('socket.io').listen(app);
...
app.listen(4000);
console.log('server started');

This question is similar, however the answer for it is simply is an updated express semantic which shouldn't apply to my code: socket.io.js not found

If my understanding is correct, the script path should work because when socket.io is running, it should direct that request to the right route. I don't really know what else I should look into for a fix, could it be something with the path in Ubuntu? Any help would be very much appreciated!

Just tested this:

var io = require('socket.io').listen(8000);

Went to localhost:8000 and the 'welcome to socket.io' message showed up so I know it is running....

paths
node_modules: /home/alex/node_modules/socket.io
my node app: /home/alex/documents/project/app.js

Community
  • 1
  • 1
Alex Roe
  • 586
  • 5
  • 11

1 Answers1

1

I had the same problem and it seemed that the reason was that something went wrong during the installation of socket.io. Actually the only workaround I found was to make a new directory, copy all your code there and do a fresh install of the Express and socket.io modules:
npm install express socket.io
Maybe I was lucky, but it worked!

Flolagale
  • 1,300
  • 11
  • 7