title: Node JS override standard module
body: <p>Friend has asked an interesting question and I've tried a few things but to no avail, is there any way to override a Node JS module?</p>
  
  <p>For instance, I want to override the readFile function to use an S3 bucket instead of the filesystem. I.E:</p>
  
  <pre><code>var fs = require('fs');
  
  fs.readFile('my_text_file.txt', ...);
  </code></pre>
  
  <p>Actually runs something like this</p>
  
  <pre><code>FileSystem.readFile = function () {
      // Connect to S3 and retrieve remote file
  }
  </code></pre>
  
  <p>I've tried the prototype but it seems they've set up native modules without the <code>__proto__</code> object, they don't have a <code>.constructor</code> property that means anything to anyone.</p>
  
  <p>I've thought about using <a href="http://nodejs.org/api/vm.html">Nodes VM</a> but this is too strict as I want the user to be able to install modules via <code>npm</code> and use them.</p>
  
  <p>The closest I've actually come is creating a new module (since I can't put a file named <code>fs.js</code> in my <code>node_modules</code> folder and require it; it just gets ignored) and just hard-setting the values of <code>fs</code> to what I want but this isn't quite right, I want the user to be using <code>require('fs')</code> and use my custom function.</p>
  
  <p>Is this at all possible without compiling my own version of Node JS?</p>