I passed the challenge using a different way but what if I had to clear the challenge by just seeing the instructions provided?
https://learn.freecodecamp.org/apis-and-microservices/basic-node-and-express/serve-an-html-file
Here’s the code:
var path = require('path');
app.get('/', function(req, res){
res.sendFile(path.join(__dirname + '/views/index.html'))
});