Node.js Getting undefined property when using require in other module

This is how my app.js looks

var app = require('http').createServer(handler),
    io = require('socket.io').listen(app),
    static = require('node-static'); // for serving files
var game = require('./game.js').createGame();

// This will make all the files in the current folder
// accessible from the web
var fileServer = new static.Server('./');

// This is the port for our web server.
// you will need to go to http://localhost:8080 to see it
app.listen(8080);

// Listen for incoming connections from clients
io.sockets.on('connection', function (socket) {
    handle Events ... 
});

exports.io = io;
exports.game = game;

when I try to access the created socket.io listner or the game instance I get error saying its undefined. This how I am trying to access it in trick,js

var game = require('./app.js').game;
var socketio = require('./app.js').io;
var PlayerMove = require('./playerMove.js');

This might be because trick.js is actually executed before app.js (I put debug points and it was confirmed there). How do I avoid this? Is there a better way of exposing object instances in node.js, some pattern that i should probably use ?

declaring a variable does not export it. If you need to export something for your module, you should use exports.myVariable = myValue.

requiring your app.js file for the first time will run it. So everything you export in it will be available once you're out of the require() call