我正在尝试从angular的服务发送一个http方法到nodejs上的一个api向服务器发送请愿书,但出现此错误:
Error: ENOENT: no such file or directory, stat 'E:\client\index.html'
这是我的代码:
//rutas
app.use('/', express.static('client', {redirect:false}));
app.use('/api', insumos_routes);
app.get('*', function(req, res, next){
res.sendFile(path.resolve('/client/index.html'));
});
//export
module.exports= app;
已经尝试过:
res.sendFile('/client/index.html');
res.sendFile('./index.html');
...喜欢说别人回答
答案 0 :(得分:0)
path.resolve
需要两个或多个参数。您需要为其提供基本路径。
例如:
path.resolve(__dirname, 'client/index.html');
您希望该路径相对于脚本所在的目录。