Reputation: 5
Hello I am new to programming and was trying to run the socket.io chat demo. However, when I try running it it gives me a error which is found at line 5 saying it can't find ('../..'). Can someone explain to me why this is happening?
Heres a snippet of the code where the issue is at:
// Setup basic express server
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('../..')(server);
var port = process.env.PORT || 3000;
server.listen(port, function () {
console.log('Server listening at port %d', port);
});
// Routing
app.use(express.static(__dirname + '/public'));
// Chatroom
The source code of the full thing is on Github
Upvotes: 0
Views: 43
Reputation: 2308
The problem is with this line. In the example they have on github it works, because it links to the socket.io library which is in the root folder.
var io = require('../..')(server);
In your case if you are trying to lauch just this example and not the whole socket.io folder you need to install socket.io library with npm.
npm install --save socket.io
After downloading the library you can require it directly:
var io = require('socket.io')(server);
Upvotes: 1