title: How can a module in node.js maintain state?
body: <p>I have two different js files that use the same module.</p>
  
  <p>file1.js:</p>
  
  <pre><code>var mod1 = require('commonmodule.js');
  mod1.init('one');
  </code></pre>
  
  <p>file2.js:</p>
  
  <pre><code>var mod2 = require('commonmodule.js');
  mod2.init('two');
  </code></pre>
  
  <p>(both these files file1.js, file2.js are loaded inside my server.js file, they themselves are modules)</p>
  
  <p>now in commonmodule.js:</p>
  
  <pre><code>var savedName;
  exports.init = function(name)
  {
      savedName = name;
  }
  exports.getName = function()
  {
      return savedName;
  }
  </code></pre>
  
  <p>I noticed that this savedName is always overridden dependent on who set it last.So it doesn't seem to work. How would I get a module to maintain state?</p>
  
  <p>Note: I also tried to set savedName as exports.savedName in the commonmodule.js but it doesn't work either</p>