You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HTML comment with an embedded EJS scriptlet [<% ... %>] causing error:[SyntaxError: Unexpected token '.' in __dirname+\views\list.ejs while compiling ejs]
#734
Closed
RahulYavvari opened this issue
May 26, 2023
· 1 comment
This is the package.json file { "name": "todo-list-v1", "version": "1.0.0", "description": "", "main": "app.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Rahul", "license": "ISC", "dependencies": { "body-parser": "^1.20.2", "ejs": "^3.1.9", "express": "^4.18.2" } }
With this HTML comment <!-- [<% .. %>] - is called a Scriptlet tag --> line in my list.ejs file in the views folder of project's root directory, when trying to run my server with nodemon app.js, it starts listening on the port 3000, then when trying to load localhost:3000, I am getting an error saying
SyntaxError: Unexpected token '.' in {__dirname}\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: true as an option.
at new Function ()
at Template.compile ({__dirname}\node_modules\ejs\lib\ejs.js:673:12)
at Object.compile ({__dirname}\node_modules\ejs\lib\ejs.js:398:16)
at handleCache ({__dirname}\node_modules\ejs\lib\ejs.js:235:18)
at tryHandleCache ({__dirname}\node_modules\ejs\lib\ejs.js:274:16)
at exports.renderFile [as engine] ({__dirname}\node_modules\ejs\lib\ejs.js:491:10)
at View.render ({__dirname}\node_modules\express\lib\view.js:135:8)
at tryRender ({__dirname}\node_modules\express\lib\application.js:657:10)
at Function.render ({__dirname}\node_modules\express\lib\application.js:609:3)
at ServerResponse.render ({__dirname}\node_modules\express\lib\response.js:1039:7)
This is the package.json file
{
"name": "todo-list-v1",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Rahul",
"license": "ISC",
"dependencies": {
"body-parser": "^1.20.2",
"ejs": "^3.1.9",
"express": "^4.18.2"
}
}
With this HTML comment
<!-- [<% .. %>] - is called a Scriptlet tag -->
line in my list.ejs file in the views folder of project's root directory, when trying to run my server withnodemon app.js
, it starts listening on the port 3000, then when trying to loadlocalhost:3000
, I am getting an error saying-------------### [ERROR MESSAGE STARTS HERE]--------------
SyntaxError: Unexpected token '.' in {__dirname}\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: true
as an option.at new Function ()
at Template.compile ({__dirname}\node_modules\ejs\lib\ejs.js:673:12)
at Object.compile ({__dirname}\node_modules\ejs\lib\ejs.js:398:16)
at handleCache ({__dirname}\node_modules\ejs\lib\ejs.js:235:18)
at tryHandleCache ({__dirname}\node_modules\ejs\lib\ejs.js:274:16)
at exports.renderFile [as engine] ({__dirname}\node_modules\ejs\lib\ejs.js:491:10)
at View.render ({__dirname}\node_modules\express\lib\view.js:135:8)
at tryRender ({__dirname}\node_modules\express\lib\application.js:657:10)
at Function.render ({__dirname}\node_modules\express\lib\application.js:609:3)
at ServerResponse.render ({__dirname}\node_modules\express\lib\response.js:1039:7)
-------------### [ERROR MESSAGE ENDS HERE]--------------
[References]
The text was updated successfully, but these errors were encountered: