title: How to check if a file or directory exists without using fs.exists?
body: <p>The reason I ask, is because Node.js on ubuntu doesn't seem to have the fs.exists() function. Although I can call this when I run Node.js on my Mac, when I deploy to the server, it fails with an error saying the function does not exist.</p>
  
  <p>Now, I am aware that some people consider it an "anti-pattern" to check if a file exists and then try and edit / open it etc, but in my case, I never delete these files, but I still need to check if they exist before writing to them.</p>
  
  <p>So how can I check if the directory (or file) exists ?</p>
  
  <p>EDIT:</p>
  
  <p>This is the code I run in a file called 'temp.'s' :</p>
  
  <pre><code>var fs=require('fs');
  fs.exists('./temp.js',function(exists){
      if(exists){
          console.log('yes');
      }else{
          console.log("no");
      }
  });
  </code></pre>
  
  <p>On my Mac, it works fine. On ubuntu I get the error:</p>
  
  <pre><code>node.js:201
          throw e; // process.nextTick error, or 'error' event on first tick
                ^ TypeError: Object #&lt;Object&gt; has no method 'exists'
      at Object.&lt;anonymous&gt; (/home/banana/temp.js:2:4)
      at Module._compile (module.js:441:26)
      at Object..js (module.js:459:10)
      at Module.load (module.js:348:32)
      at Function._load (module.js:308:12)
      at Array.0 (module.js:479:10)
      at EventEmitter._tickCallback (node.js:192:41)
  </code></pre>
  
  <p>On my Mac - version : v0.13.0-pre
  On Ubuntu - version : v0.6.12</p>