title: solving circular dependency in node using requirejs
body: <p>I have been try out many suggestions I found googling for circular dependency in node and requirejs. Unfortunately, I'm not getting it to work. The try which is closed to a solution (I think) is below:</p>
  
  <pre><code>// run.js
  var requirejs = require('requirejs');
  
  requirejs.config({
    baseUrl: __dirname,
    nodeRequire: require
  });
  
  requirejs(['A'], function(A) {
    var a = new A.Go();
    console.log(a.toon())
  });
  
  
  // A.js
  define(['B', 'exports'], function(B, exports) {
  
    exports.Go = function() {
      var b = new require('B').Ho();
      var toon = function() {
        return 'me tarzan';
      }; 
  
      return {
        b: b,
        toon: toon
      }
    };
  });
  
  
  // B.js
  define(['A', 'exports'], function(A, exports) {
  
    exports.Ho = function() {
      var a = new require('A').Go();
      var show = function() {
        return 'you jane';
      }
  
      return {
        a: a,
        show: show
      }
    };
  });
  </code></pre>
  
  <p>Running this code in node results in a RangeError: Maximum call stack size exceeded
  We the dependency of B is removed from A.js, 'me tarzan' is returned</p>
  
  <p>Any suggestion is appreciated!</p>