Configure multiple nodejs servers to share node_modules
<p>I have a VPS that I use to host client sites I build using nodeJS + Express. <code>npm</code> is my package manager and before I really knew what I was doing, I had built four sites each using modules installed with <code>npm install foo --save</code> (omitting the <code>-g</code> flag).</p>

<p>I'm now seeing that four node servers sitting behind nginx are taking up just under 50% of my (allocated) 1GB RAM. They're quite basic websites so I can't help but wonder if there is a way I can "rebuild" them to share common modules from a global install... When I ran <code>htop</code> this morning I noticed that each instance of a node server seems to have a corresponding <code>npm</code> instance running and each is using a couple of % points of available memory. Will sharing common modules be more efficient like I think it will be? If so, how do I reconfigure these sites to use shared modules?</p>

<p>My existing directory structure is setup similar to this:</p>

<pre><code>sites/
  -- site1/
    --node_modules/
  -- site2/
    --node_modules/
...
</code></pre>

<p>The biggest concern here is minimizing any downtime on these sites, second concern is maximizing performance.</p>