title: What do "module.exports" and "exports.methods" mean in NodeJS / Express?
body: <p>Looking at a random <a href="https://github.com/visionmedia/express/blob/master/lib/router/index.js">source file</a> of the <code>express</code> framework for <code>NodeJS</code>, there are two lines of the code that I do not understand (these lines of code are typical of almost all NodeJS files).</p>
  
  <pre><code>/**
   * Expose `Router` constructor.
   */
  
  exports = module.exports = Router;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>/**
   * Expose HTTP methods.
   */
  
  var methods = exports.methods = require('./methods');
  </code></pre>
  
  <p>I understand that the <em>first piece of code</em> <strong>allows the rest of the functions in the file to be exposed to the NodeJS app</strong>, but I don't understand exactly <strong>how it works</strong>, or what the code in the line means. </p>
  
  <blockquote>
    <p>What do <code>exports</code> and <code>module.exports</code> actually mean?</p>
  </blockquote>
  
  <p>I believe the 2nd piece of code allows the functions in the file to access <code>methods</code>, but again, how exactly does it do this.</p>
  
  <p>Basically, what are these magic words: <strong><code>module</code></strong> and <strong><code>exports</code></strong>?</p>