【问题标题】:SyntaxError: Unexpected token.ejs while compiling ejsSyntaxError:编译 ejs 时出现意外的 token.ejs
【发布时间】:2020-03-24 23:35:41
【问题描述】:

我的 ejs 文件路径不起作用。

SyntaxError: Unexpected token '/' in C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\views\landing.ejs 在编译 ejs 时

如果上述错误没有帮助,您可能想尝试 EJS-Lint: https://github.com/RyanZim/EJS-Lint 或者,如果您打算创建一个 async 函数,将async: true 作为选项传递。 在新函数 () 在 Template.compile (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\ejs\lib\ejs.js:626:12) 在 Object.compile (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\ejs\lib\ejs.js:366:16) 在 handleCache (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\ejs\lib\ejs.js:215:18) 在 tryHandleCache (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\ejs\lib\ejs.js:254:16) 在 View.exports.renderFile [作为引擎] (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\ejs\lib\ejs.js:459:10) 在 View.render (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\view.js:135:8) 在 tryRender (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\application.js:640:10) 在 Function.render (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\application.js:592:3) 在 ServerResponse.render (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\response.js:1012:7) 在 C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\app.js:43:9 在 Layer.handle [as handle_request] (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\router\layer.js:95:5) 在下一个(C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\router\route.js:137:13) 在 Route.dispatch (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\router\route.js:112:3) 在 Layer.handle [as handle_request] (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\router\layer.js:95:5) 在 C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\router\index.js:281:22

这是我的代码

Here is my folder structure

enter image description here 在此处输入图像描述 enter image description here

enter image description here 有人能解决这个问题吗?

【问题讨论】:

标签: javascript node.js express ejs


【解决方案1】:

landing.ejs 的代码中替换:

<%- include ./partials/header %>

用这个:

<%- include ('./partials/header') %>

对页脚也做同样的事情。

【讨论】:

  • 它有效。这应该被标记为正确答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-15
  • 2021-10-13
  • 1970-01-01
  • 1970-01-01
  • 2017-08-15
  • 1970-01-01
相关资源
最近更新 更多