Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript: res.sendFile is not a function

I'm not sure why I am getting this error. Here is my code. Express was already installed with npm install express --save

var express = require('express');
var app = express();
var fs = require('fs')
var path = require('path');

app.get('/register.html',function(req, res){
  res.sendFile(path.join(__dirname+'/register.html'));
});

var server = app.listen(process.env.PORT, function(){
    console.log("Server is listening...")
})
like image 696
Ahmed Ahmed Avatar asked Sep 12 '26 05:09

Ahmed Ahmed


1 Answers

Update express to 4.8+

npm update express --save

like image 171
wayofthefuture Avatar answered Sep 13 '26 19:09

wayofthefuture



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!