gpt4 book ai didi

node.js - 语法错误 : Unexpected Indentifier while compiling ejs file

转载 作者:太空宇宙 更新时间:2023-11-03 23:49:11 25 4
gpt4 key购买 nike

有人知道以下错误是什么原因吗?

SyntaxError: Unexpected identifier in /home/smart/Downloads/npmPackage/views/test.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 (/home/smart/Downloads/npmPackage/node_modules/ejs/lib/ejs.js:626:12) at Object.compile (/home/smart/Downloads/npmPackage/node_modules/ejs/lib/ejs.js:366:16) at handleCache (/home/smart/Downloads/npmPackage/node_modules/ejs/lib/ejs.js:215:18) at tryHandleCache (/home/smart/Downloads/npmPackage/node_modules/ejs/lib/ejs.js:254:16) at View.exports.renderFile [as engine] (/home/smart/Downloads/npmPackage/node_modules/ejs/lib/ejs.js:459:10) at View.render (/home/smart/Downloads/npmPackage/node_modules/express/lib/view.js:135:8) at tryRender (/home/smart/Downloads/npmPackage/node_modules/express/lib/application.js:640:10) at Function.render (/home/smart/Downloads/npmPackage/node_modules/express/lib/application.js:592:3) at ServerResponse.render (/home/smart/Downloads/npmPackage/node_modules/express/lib/response.js:1012:7) SyntaxError: Unexpected identifier in /home/smart/Downloads/npmPackage/views/test.ejs while compiling ejs

这是我的 ejs 文件

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<% include partials/navbar %>
<h1>This is a test Page</h1>
</body>
</html>

最佳答案

您必须将其用双引号括起来,并像函数调用一样使用。你也应该使用 <%-包括 echo documentation

您的模板应如下所示:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<%- include("./partials/navbar") %>
<h1>This is a test Page</h1>
</body>
</html>

关于node.js - 语法错误 : Unexpected Indentifier while compiling ejs file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59979886/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com