Basic Node and Express - Serve an HTML File

Tell us what’s happening:

I am getting following error in browser IDE

ENOENT: no such file or directory, stat ‘/index.html’

Your code so far

let express = require('express');
let app = express();

console.log('Hello World')


app.get('/', function(req, res){
   res.sendFile("/", __dirname + "/views/index.html")
})

 module.exports = app;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36

Challenge Information:

Basic Node and Express - Serve an HTML File

the path in sendFile is the first argument, so you are sending out whatever is at pat "/"

Hi, I’m stuck here

let app = express();




/*app.get("/", function(req, res) {
  res.send("Hello Express");
}); */


app.get("/", function(req,res){
  res.sendFile(absolutePath= __dirname +'views/index.html')
})

create your own topic to ask your questions