title: __dirname is not representing the intended path
body: <p>I'm currently struggling with an issue, trying to render an HTML file. Here's the code snippet below:</p>
  <pre><code>import http from 'http'
  import fs from 'fs'
  import path from 'path'
  
  const __dirname = path.resolve(path.dirname(''))
  
  const requestListener = (req, res) =&gt; {
      fs.readFile(__dirname + 'index.html', (err, callback) =&gt; {
          if(err) {
              res.writeHead(404)
              res.end(JSON.stringify(err))
              return
          }
          res.writeHead(200)
          res.end(callback)
      })
  }
  
  const app = http.createServer(requestListener)
  
  app.listen(8080) 
  </code></pre>
  <p>I'm not getting any errors on the console, however I'm getting the following on the browser when loading localhost:</p>
  <p><code>{&quot;errno&quot;:-4058,&quot;code&quot;:&quot;ENOENT&quot;,&quot;syscall&quot;:&quot;open&quot;,&quot;path&quot;:&quot;D:\\...&quot;}</code></p>
  <p>The status code given on the response is 404, which means I'm not actually able to load the HTML file. In addition, if I remove __dirname and pass the actual path within <code>readFile()</code> it works, though I wanted to understand why isn't dirname actually working when it should. Thanks in addition for your answers!</p>