title: NodeJS - One instance of class/module in 2 processes
body: <p>I have a class in a file that exports it, as following:</p>
  <p><strong>myClass.js:</strong></p>
  <pre class="lang-js prettyprint-override"><code>class testClass {
    key = 'initial value';
    constructor(){
      return this;
    }
  }
  
  module.exports = testClass;
  </code></pre>
  <p>Then I have 2 node files that run separately:</p>
  <pre class="lang-js prettyprint-override"><code>let instance = new require(&quot;./myClass.js&quot;);
  instance.key = 'changed value';
  // Keeps running
  </code></pre>
  <p>and</p>
  <pre class="lang-js prettyprint-override"><code>let instance = new require(&quot;./myClass.js&quot;);
  console.log(instance.key);
  // Also keeps running
  </code></pre>
  <hr />
  <h2>Question</h2>
  <p>How can I make the second process print &quot;changed value&quot; instead of &quot;initial value&quot;?</p>
  <p>Notes:</p>
  <ul>
  <li>I tried running the 2nd file after the 1st one;</li>
  <li>This is a very simplified example of what I need, I changed the context to make it more understandable.</li>
  </ul>