title: NodeJs Require module returns an empty object
body: <p>I'm using NodeJS 8 LTS.</p>
  
  <p>I have 3 js scripts where:</p>
  
  <pre><code>// main.js
  const dom = require ('./Domains/Domains');
  const factory = require ('./Domains/Factory');
  (async () =&gt; {
      const Domain = await factory.foo();  // &lt;=== Error
  
  })();
  
  // Domains.js
  class Domains {
      constructor (options = {}) {
          ....
      }
  }
  module.exports = Domains;
  
  // Factory.js
  const Domains = require('./Domains');
  module.exports = {
     foo: async () =&gt;{
  
        .... async stuff ...
  
       return new Domains();
      }
  };
  </code></pre>
  
  <p>when I run <code>main.js</code> I get</p>
  
  <pre><code>(node:1816) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Domains is not a constructor
  warning.js:18
  (node:1816) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  </code></pre>
  
  <p>Debugging, I found that in <code>Factory.js</code> when it requires Domanis.js <code>const Domains = require('./Domains');</code> it returns an empty object.</p>
  
  <p>Looking around on internet I found that it happens when there are a circular dependencies between modules (<a href="https://stackoverflow.com/questions/23875233/require-returns-an-empty-object/23875299">Require returns an empty object</a>) but It doesn't seem the case here.</p>
  
  <p>Any idea?</p>