title: Why is my fs error returning an empty object in Node.js?
body: <p>I am currently trying to read a file using <code>fs</code> in Node v12.16.2. I currently have a function setup like so:</p>
  
  <pre class="lang-js prettyprint-override"><code>const fs = require('fs');
  var JSONData;
  const read = function(path){
      fs.readFile(path, 'utf8', (data, err) =&gt; {
          if(err){
              console.log(err);
              console.log('there was an error');
          }
          JSONData = data;
      })
  }
  read('./path/to/file.json');
  </code></pre>
  
  <p>In the console, I simply get</p>
  
  <pre><code>{}
  there was an error
  </code></pre>
  
  <p>I also tried <code>console.log</code>ing <code>err.message</code>, <code>err.valueOf</code>, and using <code>throw err</code>, none of which gave me any more data on the error. I'd appreciate if someone could help either discover my problem or knows it already.</p>