title: How to stub/mock submodules of a require of nodejs using sinon
body: <p>I am using sinon as for unit testing a nodejs(Hapijs) functionality. This function is in index.js. I am include the index.js in my test file as </p>
  
  <pre><code>    var index=require('./index.js');
  </code></pre>
  
  <p>But again inside the index.js there is require</p>
  
  <pre><code>    var library= require('./library.js')
  </code></pre>
  
  <p>Again the library.js has the require of a third part functionality</p>
  
  <pre><code>     var googlelib=require('googlelib')
  </code></pre>
  
  <p>Now when I run my testfile testfunc.js below</p>
  
  <pre><code>    var index= require('./index.js');
      var assert = require('assert');
      var sinon = require('sinon');
      var proxyquire= require('proxyquire');
  </code></pre>
  
  <p>I get the below error </p>
  
  <pre><code>    Error: Cannot find module './library'
      at Function.Module._resolveFilename (module.js:555:15)
      at Function.Module._load (module.js:482:25)
      at Module.require (module.js:604:17)
      at require (internal/module.js:11:18)
  </code></pre>
  
  <p>I would like to know if there is any way I can stub the inner require library.js of index.js (as there are many requires inside index.js and many requires of requires)</p>