title: Node.js + Express: What do I have to serve the specific folder's path to express.static?
body: <p>I wrote the following code:</p>
  
  <pre><code>var express = require('express');
  var app = express();
  
  app.use('/', express.static(__dirname ));
  
  app.get('/', function (req, res) {
    res.sendFile('./dist/index.html');
  });
  
  
  app.listen(3000, function() {
    console.log("Listening on port 3000");
  });
  </code></pre>
  
  <p>which doesn't work. When open the browser and go to "localhost:3000" I get the error: </p>
  
  <blockquote>
    <p>path must be absolute or specify root to res.sendFile</p>
  </blockquote>
  
  <p>Of course the once I fix the line that starts with "app.use..." to: </p>
  
  <pre><code>app.use('/', express.static(__dirname + "./dist"));
  </code></pre>
  
  <p>then everything works right. </p>
  
  <p>Can you please explain why? What's wrong with giving "express.static" a path of a parent folder of the direct folder of the file sent?  </p>