We help IT Professionals succeed at work.

NodeJS Paths to Socket.IO Issue

New to NodeJS, having trouble with path description to modules, both server and client side. I'm Node and Linux challenged.

Both server.js and index.html resides at "/opt/mydir/www/workingDirectory/"
socket.io resides at "/usr/lib/node_modules/socket.io"
socket.io.js resides at "/usr/lib/node_modules/socket.io/node_modules/socket.io-client/socket.io.js"

so in server.js :  var socketio = require('./usr/lib/node_modules/socket.io');    (not sure is this is correct??)
index.html: <script type="text/javascript" src="./usr/lib/node_modules/socket.io/node_modules/socket.io-client/socket.io.js"></script>
the path in index.html must be wrong, I'm getting a js error in Firefox console:
"Reference error: io is not defined
var iosocket = io.connect();

any assistance would be appreciated
Comment
Watch Question

Fixer of Problems
Most Valuable Expert 2014
Commented:
I suspect that the dot in './' is your problem because that makes it relative to the current directory.  Remove the dot and use just '/' because those are absolute paths on the server.

Author

Commented:
So I think the path issue is okay now, but still not able to get the server up. constantly getting the "Error: listen EADDRINUSE" no matter what port I specify in listen:
var app = require("/usr/lib/node_modules/express");
var server = require("http").createServer();
var io = require("/usr/lib/node_modules/socket.io")(server);

server.listen(8008);

console.log("server running");

io.on("connection", function (socket) {
    var tweet = {user: "nodesource", text: "Hello, world!"};

    // to make things interesting, have it send every second
    var interval = setInterval(function () {
        socket.emit("tweet", tweet);
    }, 1000);

    socket.on("disconnect", function () {
        clearInterval(interval);
    });
});