有人知道下面的错误是什么吗?
/home/smart/Downloads/npmPackage/views/test.ejs中的SyntaxError:编译ejs时的意外标识符 如果上面的错误没有帮助,您可能希望尝试EJS:https://github.com/RyanZim/EJS-Lint,或者,如果要创建异步函数,可以将
async: true
作为选项传递。(/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 作为发动机 at View.render 作为发动机 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 (/home/smart/Downloads/npmPackage/node_modules/express/lib/response.js:1012:7) SyntaxError:编译ejs时/home/smart/Downloads/npmPackage/views/test.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>
发布于 2020-01-30 06:08:17
你必须把它和双引号放在一起,让它像函数调用一样。此外,您还应该使用<%-
来包括回显文档。
您的模板应该如下所示:
<!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>
https://stackoverflow.com/questions/59979886
复制相似问题