'yntaxError: Invalid or unexpected token
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: trueas 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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
