nodejs ejs使用include引入公共文件报错SyntaxError: Unexpected identifier

ejs 3.1.5版本,根据网上的视频教程,使用include引用公共部分的html文件时出现错误

引入代码

<%include footer.html%>

报错

SyntaxError: Unexpected identifier in E:\project\nodejs\views\index.html 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 (<anonymous>)
    at Template.compile (E:\project\nodejs\node_modules\_ejs@3.1.5@ejs\lib\ejs.js:661:12)
    at Object.compile (E:\project\nodejs\node_modules\_ejs@3.1.5@ejs\lib\ejs.js:396:16)
    at handleCache (E:\project\nodejs\node_modules\_ejs@3.1.5@ejs\lib\ejs.js:233:18)
    at tryHandleCache (E:\project\nodejs\node_modules\_ejs@3.1.5@ejs\lib\ejs.js:272:16)
    at View.exports.renderFile [as engine] (E:\project\nodejs\node_modules\_ejs@3.1.5@ejs\lib\ejs.js:489:10)
    at View.render (E:\project\nodejs\node_modules\_express@4.17.1@express\lib\view.js:135:8)
    at tryRender (E:\project\nodejs\node_modules\_express@4.17.1@express\lib\application.js:640:10)
    at Function.render (E:\project\nodejs\node_modules\_express@4.17.1@express\lib\application.js:592:3)
    at ServerResponse.render (E:\project\nodejs\node_modules\_express@4.17.1@express\lib\response.js:1012:7)

网上搜索后,改成下面的写法后,问题解决

<%-include ("footer.html")%>

原因可能是ejs版本问题~

关键词: nodejs