node.js 表达js错误:“表达不推荐使用的res.sendfile:改用res.sendFile”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26202150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
express js error : "express deprecated res.sendfile: Use res.sendFile instead"
提问by hash
What is the right way to set path?
设置路径的正确方法是什么?
in my app i this code for i use set path for sending file.
在我的应用程序中,我使用设置路径发送文件的代码。
app.get('/',function(req, res){//get,put,post,delete
res.sendfile(__dirname + '/client/views/index.html');
});
but it give this error:
但它给出了这个错误:
express deprecated res.sendfile: Use res.sendFile instead server.js:22:6
can some to point what is the error here.please
可以有人指出这里的错误是什么。请
回答by Jayram
Change this
改变这个
app.get('/',function(req, res){//get,put,post,delete
res.sendfile(__dirname + '/client/views/index.html');
});
to this and this should work.
对此,这应该有效。
app.get('/',function(req, res){//get,put,post,delete
res.sendFile(__dirname + '/client/views/index.html');
});
In new versions sendfilehas been deprecated. Change sendfileto sendFile.
在新版本中sendfile已被弃用。更改sendfile为sendFile。
回答by iffishells
Short Answer : replace res.sendfile with res.sendFile .i will give you a example with code :
简短回答:用 res.sendFile 替换 res.sendfile 。我会给你一个代码示例:
app.get("/" ,function(req,resp){
resp.sendfile(__dirname + "/index.html")})
<p>replace with this</p>
app.get("/" ,function(req,resp){
resp.sendFile(__dirname + "/index.html")})

