0

I am using express version : express@4.12.3

And while supplying the static html i use the following:

app

    .get('*', function (req, res) {
        res.sendFile('public/main.html');
    })

But I am getting error as :

TypeError: path must be absolute or specify root to res.sendFile

Instead if i use the res.sendfile - works but i am getting error from cmd saying to use sendFile - what else i do? what is the issue here?

any one guide me please?

3gwebtrain
  • 14,640
  • 25
  • 121
  • 247

1 Answers1

2

Try this instead of writing the relative path :

    res.sendFile(__dirname +'/public/main.html');
Sumit Sinha
  • 666
  • 3
  • 9
  • 18