Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Socket.io.js not found on Ubuntu but is on Windows

Socket.io.js not found on Ubuntu but is on Windows

Problem

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:

I've even tried

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

Problem courtesy of: Alex Roe

Solution

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!

Solution courtesy of: Flolagale

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Socket.io.js not found on Ubuntu but is on Windows

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×