【问题标题】:How to debug EJS templates in Node/Express如何在 Node/Express 中调试 EJS 模板
【发布时间】:2015-05-25 04:43:41
【问题描述】:

我正在将 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 文件?

【问题讨论】:

    标签: javascript node.js express


    【解决方案1】:

    我同意错误消息是模糊的! 有一些开源应用程序在其应用程序中进行了更好的错误处理。 我用Mean.Js

    他们的信息更容易理解,它实际上指向一行代码并给你一些纠正它的提示。 它易于使用。

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 2015-07-17
      • 2020-12-24
      • 1970-01-01
      • 2019-01-07
      • 2021-10-11
      • 2020-05-28
      • 2015-07-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多