title: Can node modules require each other
body: <p>I'm having the following 3 files.</p>
  
  <p>user.js requires room.js and room.js requires user.js.</p>
  
  <p>user.js</p>
  
  <pre><code>var Room = require('./room.js');
  
  var User = function () {};
  User.prototype.test = function () {
    return new Room();
  };
  
  module.exports = User;
  </code></pre>
  
  <p>room.js</p>
  
  <pre><code>var User = require('./user.js');
  
  var Room = function () {};
  Room.prototype.test = function () {
    return new User();
  };
  
  module.exports = Room;
  </code></pre>
  
  <p>index.js</p>
  
  <pre><code>var User = require('./user.js');
  var Room = require('./room.js');
  
  var user = new User();
  var room = new Room();
  
  user.test();
  room.test();
  </code></pre>
  
  <p>index.js requires both room and user.</p>
  
  <p>Here's the problem. When I run index.js, I will get a TypeError from 'new User()' in room.js. It seems that User in room.js is hidden by the User in index.js.</p>
  
  <p>Am I doing anything wrong? Is this kind of requiring allowed? Any ideas? Thanks.</p>