Sendfile noworking in express


I’m a beginner in node and express. I’m trying to create a node application where I’m trying to load an HTML file once client connected to then server successfully. below is my source code.

var http = require(‘http’);
var express = require(‘express’);
var application = express();
var path = require(‘path’);
var server = require(‘http’).createServer(application);

application.get(’/’, function(req, res){


When I run the app. I got below mentioned error. I ave
"Error: ENOENT: no such file or directory, stat '/test.html’
at Error (native)"

Kindly help me.


Can you try changing res.sendfile(path.resolve('/test.html')); to res.sendfile(path.resolve(__dirname, 'test.html'));? That should add the rest of the path before test.html, and correctly point to the file.