title: Can I put the npm node_modules directory outside of my 'webroot'
body: <p>I'm new to Node but am enjoying myself so far.  I was trying to move my <code>node_modules</code> (libraries) directory outside of the public 'webroot' and need advice and guidance.</p>
  
  <p>I've setup my simple <a href="http://expressjs.com/" rel="noreferrer">expressJS</a> based Node project as follows:</p>
  
  <pre><code>/my_project
    /config
    /public          
       /node_modules
       server.js
  </code></pre>
  
  <p>I was wondering if there was any way I could have the <code>/node_modules</code> dir outside of my webroot and not break my application.  I'm just so used to keeping the bare minimum in my publicly exposed webroot and don't feel right with the libs being in there.  Call me old fashioned but that's how I'm used to doing stuff in the PHP and C# world.</p>
  
  <p>If I setup the project as follows:</p>
  
  <pre><code>/my_project
    /config
    /node_modules
    /public          
       server.js
  </code></pre>
  
  <p>then it all goes wobbly and Node's <code>require()</code> magic breaks.</p>
  
  <p>I've tried the following:</p>
  
  <p><code>var express=require('../express');</code> which doesn't work either giving me the 'Cannot Find module' type error.</p>
  
  <ol>
  <li>Is what I'm asking even possible, if so then how?</li>
  <li>Are there any major risks with me having my libs in a webroot or have I missed something fundamental here with the way Node works.</li>
  <li><strike> What do you guys do, what is best practice for production apps?</strike> May I have some examples of your production practices and why.</li>
  </ol>