我正在学习一个基本的 MEAN 教程,但我已经碰壁了。出现“TypeError: res.sendFile is not a function”错误
//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');
最佳答案
请重新安排回调参数:
function(req,res){}
例子:
app.get('/',function(req, res){
res.sendFile(path.join(__dirname+'/index.html'));
});
关于javascript - TypeError : res. sendFile 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35150431/