title: module.exports returns empty object
body: <p>I have a separate js file that exports the mongoDB connection so the other files can use it without creating a new connection. (one of mongoDB's best practices)</p>
  <h3>mongoClient.js (returns the connected client)</h3>
  <pre class="lang-js prettyprint-override"><code>// Defining the MongoClient
  
  const { MongoClient } = require(&quot;mongodb&quot;);
  const mongo = new MongoClient(
      process.env.MONGO_AUTH,
      {
          useNewUrlParser: true,
          useUnifiedTopology: true,
      }
  );
  
  mongo.connect((err, result) =&gt; {
  
      // result == mongo ✅
      module.exports = result;
  
      console.log(module.exports); // When the script is run alone, it works. When it's required somewhere else, nothing is logged (is it executed?)
      
      process.on(&quot;SIGINT&quot;, function () {
          mongo.close();
      });
  
  });
  </code></pre>
  <p>As written above, <code>module.exports</code> seems to work. When I require it in another file, there is no export found:</p>
  <h3>in other files</h3>
  <pre class="lang-js prettyprint-override"><code>const mongo = require(&quot;../mongoClient&quot;);
  console.log(mongo); // {}
  </code></pre>
  <p>I've heard about something called <strong>cyclic dependencies</strong>. It seems to correspond with my case, with one difference... there is none. <code>mongoClient.js</code>'s only dependency is the <code>mongodb</code> node_module (which, besides, is nowhere else in the other files). Then, where is the mistake, and how could I solve it?</p>