My server structure is simple. I have a public folder at the same level as my app.'s
app.js node_modules(folder) express(folder) socket.io(folder) public(folder) index.html js(folder) css(folder) My app.'s is as follows
var sys = require('sys'), express = require('express'), app = express.createServer('127.0.0.1'), io = require('socket.io'); app.use(express.static(__dirname + '/public')); app.get('/', function (req, res) { res.send('Hello World'); }); app.listen(3000); var socket = io.listen(app); socket.on('connection', function (client){ // new client is here! }); And my html page(simplified) is
<html> <p id="text">socket.io</p> <script src="/socket.io/socket.io.js"></script> <script type="text/javascript" src="js/lib/jquery-1.4.2.min.js"></script> </html> When I run the server and load my index.html, socket.io.js is NOT found, a 404 error is generated. What gives? In my case does socket.IO have to be installed globally?
socket.io.jsexist in the folder/public/socket.io/?