title: Asynchronous nodejs module exports
body: <p>I was wondering what the best approach is for configuring a module export. "async.function" in the example below could be a FS or HTTP request, simplified for the sake of the example:</p>
  
  <p>Here's example code (asynmodule.js):</p>
  
  <pre><code>var foo = "bar"
  async.function(function(response) {
    foo = "foobar";
    // module.exports = foo;  // having the export here breaks the app: foo is always undefined.
  });
  
  // having the export here results in working code, but without the variable being set.
  module.exports = foo;
  </code></pre>
  
  <p>How can I export the module only once the async callback has been executed? </p>
  
  <p><em>edit</em> 
  a quick note on my actual use-case: I'm writing a module to configure nconf (<a href="https://github.com/flatiron/nconf">https://github.com/flatiron/nconf</a>) in an fs.exists() callback (i.e. it will parse a config file and set up nconf). </p>