node.js之Bug集结

*、Error: Can't set headers after they are sent.

第一种:node.js采用异步响应机制,故res.send()若出现多次那么会出现上一个响应流已关闭从而造成异常
解决方案是注释掉多余的res.send();
第二种:跟踪具体代码将setHeader();出错的那一行注释即可,此法有潜在危险,慎重选择

*、Failed to lookup view "/searchUser.ejs" in views directory

路由异常,路径写的有问题,查看代码的具体跳转指令

猜你喜欢

转载自lbovinl.iteye.com/blog/2347827