YntaxError:无效或意外的令牌

发布于 2025-01-22 09:43:06 字数 1933 浏览 1 评论 0原文

在我的EJS文件中:

    <!DOCTYPE html>
    <html lang="en" dir="ltr">
      <head>
        <meta charset="utf-8">
        <title>To do List</title>
      </head>
      <body>
        <% if (kindOfDay === “Saturday” || kindOfDay === “Sunday”) { %>
          <h1 style="color: green"><%= kindOfDay %> List </h1>
        <% } else { %>
          <h1 style="color: blue"><%= kindOfDay %> List </h1>
        <% } %>
      </body>
    </html>

当代码为:

    <h1>it's a<%= kindOfDay %> List </h1>

有效时,但现在显示:

syntaxerror:/users/annezhang/desktop/test/views/list.ejs in comply ejs

in/users/annezhang/desktop/test/list.ejs中的无效或意外令牌

如果以上错误无用,则可能需要尝试EJS-lint: https://github.com/ryanzim/ejs-lint 或者,如果您打算创建异步函数,请将async:true作为选项传递。 在新功能() 在template.compile(/users/annezhang/desktop/test/node_modules/ejs/lib/ejs.js:js:662:12) 在object.compile(/users/annezhang/desktop/test/node_modules/ejs/lib/ejs.js:js:396:16) 在handlecache(/users/annezhang/desktop/test/node_modules/ejs/lib/ejs.s.js:233:18) 在tryhandlecache(/users/annezhang/desktop/test/node_modules/ejs/lib/ejs.js:js:272:16) at View.exports.renderfile [AS Engine](/Users/annezhang/desktop/test/node_modules/ejs/lib/ejs.js.js:489:10) at View.render(/Users/annezhang/desktop/test/node_modules/express/lib/view.js:135:8) 在TryRender(/Users/annezhang/desktop/test/node_modules/express/lib/application.js:640:10) at function.render(/users/annezhang/desktop/test/node_modules/express/lib/application.js:592:3) 在serverresponse.render(/Users/annezhang/desktop/test/node_modules/express/lib/response.js:1017:7)

我不确定问题是什么。

In my EJS file:

    <!DOCTYPE html>
    <html lang="en" dir="ltr">
      <head>
        <meta charset="utf-8">
        <title>To do List</title>
      </head>
      <body>
        <% if (kindOfDay === “Saturday” || kindOfDay === “Sunday”) { %>
          <h1 style="color: green"><%= kindOfDay %> List </h1>
        <% } else { %>
          <h1 style="color: blue"><%= kindOfDay %> List </h1>
        <% } %>
      </body>
    </html>

When the code is:

    <h1>it's a<%= kindOfDay %> List </h1>

it works, but now it shows:

SyntaxError: Invalid or unexpected token in /Users/annezhang/Desktop/test/views/list.ejs while compiling ejs

If the above error is not helpful, you may want to try EJS-Lint:
https://github.com/RyanZim/EJS-Lint
Or, if you meant to create an async function, pass async: true as an option.
at new Function ()
at Template.compile (/Users/annezhang/Desktop/test/node_modules/ejs/lib/ejs.js:662:12)
at Object.compile (/Users/annezhang/Desktop/test/node_modules/ejs/lib/ejs.js:396:16)
at handleCache (/Users/annezhang/Desktop/test/node_modules/ejs/lib/ejs.js:233:18)
at tryHandleCache (/Users/annezhang/Desktop/test/node_modules/ejs/lib/ejs.js:272:16)
at View.exports.renderFile [as engine] (/Users/annezhang/Desktop/test/node_modules/ejs/lib/ejs.js:489:10)
at View.render (/Users/annezhang/Desktop/test/node_modules/express/lib/view.js:135:8)
at tryRender (/Users/annezhang/Desktop/test/node_modules/express/lib/application.js:640:10)
at Function.render (/Users/annezhang/Desktop/test/node_modules/express/lib/application.js:592:3)
at ServerResponse.render (/Users/annezhang/Desktop/test/node_modules/express/lib/response.js:1017:7)

I’m not sure what is the problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文