title: Node.js Getting undefined property when using require in other module
body: <p>This is how my app.js looks </p>
  
  <pre><code>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;
  </code></pre>
  
  <p>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 </p>
  
  <pre><code>var game = require('./app.js').game;
  var socketio = require('./app.js').io;
  var PlayerMove = require('./playerMove.js');
  </code></pre>
  
  <p>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 ? </p>