I am working through a basic MEAN tutorial, and I am already hitting a wall. Getting 'TypeError: res.sendFile is not a function' error
//package.json
{
"name": "http-server",
"main": "server.js",
"dependencies": {
"express": "^4.13.4"
}
}
//server.js
var express = require('express');
var app = express();
var path = require('path');
app.get('/', function (res, req) {
res.sendFile(path.join(__dirname + '/index.html'));
});
app.listen(1337);
console.log('Visit me at http://localhost:1337');
Please re-arrange callback arguments:
function(req,res){}
Example:
app.get('/',function(req, res){
res.sendFile(path.join(__dirname+'/index.html'));
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With