如何调试Node/Express中的EJS模板
How to debug EJS templates in Node/Express
我正在将PHP模板转换为Node.js/Express中的EJS。模板文件有些复杂,因此调试它们并不容易。Node没有给我任何有用的调试信息,所以它使这个任务几乎不可能完成。下面是一个示例错误消息:
SyntaxError: Unexpected string in "app/views/profile/index.ejs"
at Object.Function (<anonymous>)
at exports.compile (/Users/Gavin/Web/node_modules/ejs/lib/ejs.js:237:14)
at Object.exports.render (/Users/Gavin/Web/node_modules/ejs/lib/ejs.js:284:10)
at View.exports.renderFile [as engine] (/Users/Gavin/Web/node_modules/ejs/lib/ejs.js:318:20)
at View.render (/Users/Gavin/Web/node_modules/express/lib/view.js:76:8)
at Function.app.render (/Users/Gavin/Web/node_modules/express/lib/application.js:502:10)
at ServerResponse.res.render (/Users/Gavin/Web/node_modules/express/lib/response.js:777:7)
at Object.exports.profile_index [as handle] (/Users/Gavin/Web/app/controllers/routes/profile.js:72:6)
at next_layer (/Users/Gavin/Web/node_modules/express/lib/router/route.js:103:13)
at Object.exports.verify_user [as handle] (/Users/Gavin/Web/app/controllers/routes/account.js:305:10)
找到这样一个模糊的错误信息的来源是非常繁琐的。是否有更简单的方法来调试EJS文件?
我同意错误消息是模糊的!有一些开源应用程序在它们的应用程序中做了更好的错误处理。我使用Mean.Js
他们的消息更容易理解,它实际上指向一行代码,并给你一些纠正它的提示。它很容易使用。
我希望它有帮助!
相关文章:
- node.js和express中的异常处理
- 将路由处理程序委托给NodeJS+Express中的其他模块
- NodeJS Express中的分页方法
- 在何处定义express中的数据库逻辑
- 处理 Node.js 和 Express 中的 404、500 和异常
- 验证 Node/Express 中的 pubsubhubbub 内容签名
- 循环访问 Express 中的嵌套对象
- 如何有条件地验证在 Oracle Application Express 中的项目上创建的验证
- NodeJS Express 中的异步操作
- nodejs/express 中的数据库会话支持
- 如何在node.js Express中的async.each中使用请求
- Nodejs和Express中的动态配置文件
- 使用require-Node js在客户端访问express中的函数
- 更快地封锁Express中的所有路线
- 处理& lt; select>在node.js/express中的Form参数
- 如何正确处理Express中的错误
- 如何将jade定义为node.js Express中的全局变量
- 如何调试Node/Express中的EJS模板
- 从Express中的POST请求处理程序下载文件
- 验证nodejs + express中的url以处理错误的请求错误