Deploying node app with self-maintained NPM modules
<p>I am developing a very complex app that is using internally developed, open source NPM modules.
I often need to change one of those modules (extra features, bug fixing, etc.) in order for the main application to work.
At the moment, I have:</p>

<ul>
<li>A directory called <code>my_modules</code>, each containing a git repository one for each module. For example <code>module1</code>, <code>module2</code>.</li>
<li>A directory called <code>my_apps</code>, where for example there is <code>app1</code> which has  <code>module1</code> as a dependency</li>
<li>Under <code>my_apps/app1/node_modules</code> I have <code>module1</code> and <code>module2</code>, installed via NPM</li>
<li>In the server, deploy by pulling the git repository, running an <code>npm install</code> and <code>npm dedupe</code>, and running the server with forever.</li>
</ul>

<p>At this stage, if I have to fix something in one of the modules, I:</p>

<ul>
<li>Fix it within <code>my_apps/app1/node_modules/module1</code> (not git)</li>
<li>When it's all working, COPY the files over to <code>my_modules/module1</code> and do a <code>git push</code> and <code>npm publish</code></li>
<li>The server will pull the latest modules after deploy thanks to <code>npm install</code></li>
</ul>

<p>This is way, way less than ideal. It's just too error-prone. However:</p>

<ul>
<li><p>Having a symbolic link link <code>my_apps/app1/node_modules/module1</code> => <code>my_modules/module1</code> means that module1 will look for dependencies in its own path, which often causes problems (for example, I need to make sure that EVERY module uses the same copy of <code>module1</code>, which is imperative)</p></li>
<li><p>Having a git repo under <code>my_apps/app1/node_modules/module1</code> feels dangerous, in case I accidentally overwrite changes using NPM on the module. Also, once fixed the change in the local git repo, I would still then need to pull the changes in <code>my_modules/module1</code>. Yes a step forward from copying files over...</p></li>
</ul>

<p>What's the "recommended" way of dealing with this? Any best practices?</p>