我正在尝试从与服务器目录处于同一级别的客户端目录中导入sendFile index.html,并出现以下错误:

TypeError: undefined is not a function
at Object.handle (/myapp/server/routes/routes.js:24:7)

这是我的routes.js的第24行:res.sendFile(path.join(__dirname + '../client/dashboard/index.html'));
全功能
dashRouter.get('/', function(req, res) {

    console.log('try to load dashboard');
    // res.render('../index.html');
    // res.send('dashboard!');
    res.sendFile(path.join(__dirname + '../client/dashboard/index.html'));
});

return dashRouter;

我的文件夹结构:


使用Express 4.10.0
您知道为什么我在res.sendFile行上收到未定义的错误吗?

最佳答案

该错误非常简单。该函数称为“sendfile”,而不是我期望的“sendFile”。

07-27 19:05