javascript - 编译 ejs 时出现语法错误 : Unexpected token. ejs

标签 javascript node.js express ejs

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

SyntaxError: Unexpected token '/' in C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\views\landing.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 (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\ejs\lib\ejs.js:626:12) at Object.compile (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\ejs\lib\ejs.js:366:16) at handleCache (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\ejs\lib\ejs.js:215:18) at tryHandleCache (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\ejs\lib\ejs.js:254:16) at View.exports.renderFile [as engine] (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\ejs\lib\ejs.js:459:10) at View.render (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\view.js:135:8) at tryRender (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\application.js:640:10) at Function.render (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\application.js:592:3) at ServerResponse.render (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\response.js:1012:7) at C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\app.js:43:9 at Layer.handle [as handle_request] (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\router\layer.js:95:5) at next (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\router\route.js:137:13) at Route.dispatch (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (C:\Users\mikda\Desktop\ColtFULL\Section33\YelpCamp\v3\node_modules\express\lib\router\layer.js:95:5) at 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 有人能解决这个问题吗?

最佳答案

landing.ejs 代码中替换:

<%- include ./partials/header %>

这样:

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

对页脚也执行相同的操作。

关于javascript - 编译 ejs 时出现语法错误 : Unexpected token. ejs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59103634/

相关文章:

javascript - 单元测试中的 Passport JWT 身份验证 - 套接字挂断

mysql - 如何防止nodejs中的sql注入(inject)和 Sequelize ?

node.js - 将 auth0 集成到 web 应用程序 express/node js 中

javascript - HTML Canvas : Animation Delay

javascript - Electron 获胜.unmaximize();不工作

node.js - Node : why should one close down the process when an error occurs?

node.js - 客户端 IP 有时在使用 CloudFlare 和 Nginx 托管在 Ubuntu 中的 Nodejs 应用程序中未定义

javascript - 范围输入 WP 定制器上出现无效值错误

javascript - 在 Grunt 任务中运行命令

javascript - 如何让Div中的所有链接在同一个窗口中打开