简体   繁体   English

如何在Node / Express中调试EJS模板

[英]How to debug EJS templates in Node/Express

I'm converting PHP templates over to EJS in Node.js/Express. 我正在将Node模板转换为Node.js / Express中的EJS。 The template files are somewhat complex, so debugging them is not easy. 模板文件有点复杂,因此调试它们并不容易。 Node isn't giving me any useful information for debugging, so it's making this task near impossible. Node没有给我任何有用的调试信息,因此它几乎不可能完成这项任务。 Here's a sample error message. 这是一个示例错误消息。

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)

Finding the source of such a vague error message is extremely tedious. 找到这种模糊错误消息的来源非常繁琐。 Is there an easier way to debug EJS files? 有没有更简单的方法来调试EJS文件?

I agree that Error Messages are vague! 我同意错误消息含糊不清! There are some open source applications which are making better Error handling in their applications. 有一些开源应用程序在其应用程序中进行了更好的错误处理。 I use Mean.Js 我用Mean.Js

Their messages are easier to understand and it actually point to a line of code and give you some hint to correct it. 他们的消息更容易理解,它实际上指向一行代码并给你一些提示来纠正它。 Its easy to work with. 它易于使用。

I hope it helps! 我希望它有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM