title: Do the NPM modules in my node app share dependencies?
body: <p>I have an app that I'm working on that is three separate modules. All three modules will be packaged separately and stored in a private NPM repository. So each module will have it's own <code>index.js</code>, <code>package.json</code>, etc.</p>
  <p><code>Module A</code> depends on <code>Module B</code> and <code>Module C</code>. <code>Module B</code> depends on <code>Module C</code>.</p>
  <p><a href="https://i.stack.imgur.com/IE9wH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IE9wH.png" alt="Dependency Chart" /></a></p>
  <p>Because <code>Module A</code> and <code>Module B</code> both have a dependency on <code>Module C</code>, will they share the dependency?</p>
  <p>For instance, let's say that <code>Module C</code> has a <code>singleton.js</code> file that returns a <code>singleton</code>.</p>
  <p><strong>singleton.js</strong></p>
  <pre><code>class MyClass {
  
  }
  
  const instance = new MyClass();
  
  module.exports = instance;
  </code></pre>
  <p>And then the <strong>index.js</strong> for <code>Module C</code> exports that as well.</p>
  <pre><code>const myClassSingleton = require('./lib/singleton.js')
  
  module.exports = myClassSingleton;
  </code></pre>
  <p>If both <code>Module A</code> and <code>Module B</code> <code>require</code> <code>Module C</code></p>
  <pre><code>const moduleC = require('module-c');
  </code></pre>
  <p>Are they both sharing that same instance of that <code>Singleton</code>?</p>