title: Setting a path for require in node.js
body: <p>I have a folder structure like this.</p>
  
  <ul>
  <li><p><code>include/</code></p>
  
  <ul>
  <li><code>index.js</code></li>
  <li><p><code>plugin/</code></p>
  
  <ul>
  <li><code>plugin.js</code></li>
  <li><code>helper.js</code></li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>Where:-</p>
  
  <blockquote>
    <p>include/index.js</p>
  </blockquote>
  
  <pre><code>//Function for mapping the path of  "require" statement in  the plugin.js file.
  
  var mapRequirePath = function(){
  
      var plugins = require('./plugin/plugin');
       return plugins;
  }
  
  //Now call the plugins..
  var plugin = mapRequirePath();
  </code></pre>
  
  <blockquote>
    <p>include/plugin/plugin.js</p>
  </blockquote>
  
  <pre><code>    /*
         I want all four require statements to point to the same file location '/include/plugin/helper.js'
  
        i.e search in the same folder location for module irrespective of the '../' or '../../' present in the require statement
      */
  
      var helper1 = require('./helper');
      var helper2 = require('helper');
      var helper3 = require('../../helper');
      var helper4 = require('../helper');
  </code></pre>
  
  <p>I want to map the path of <code>require</code> in <code>plugin.js</code> file so that all require call should search for its module in the <code>same directory only</code>. </p>