DEV Community

Discussion on: Build a simple app using Node JS and MySQL.

Collapse
 
polarfoxoff profile image
PolarFoxOFF

Hello, I tried activating app.js and it works, but when I tried to access my localhost: 5000, it happened

SyntaxError: Unexpected identifier in /Users/apple/Documents/NodeJS/views/index.ejs while compiling ejs

If the above error is not helpful, you may want to try EJS-Lint:
github.com/RyanZim/EJS-Lint
Or, if you meant to create an async function, passasync: trueas an option.
at new Function ()
at Template.compile (/Users/apple/Documents/NodeJS/node_modules/ejs/lib/ejs.js:626:12)
at Object.compile (/Users/apple/Documents/NodeJS/node_modules/ejs/lib/ejs.js:366:16)
at handleCache (/Users/apple/Documents/NodeJS/node_modules/ejs/lib/ejs.js:215:18)
at tryHandleCache (/Users/apple/Documents/NodeJS/node_modules/ejs/lib/ejs.js:254:16)
at View.exports.renderFile as engine
at View.render (/Users/apple/Documents/NodeJS/node_modules/express/lib/view.js:135:8)
at tryRender (/Users/apple/Documents/NodeJS/node_modules/express/lib/application.js:640:10)
at Function.render (/Users/apple/Documents/NodeJS/node_modules/express/lib/application.js:592:3)
at ServerResponse.render (/Users/apple/Documents/NodeJS/node_modules/express/lib/response.js:1012:7)
SyntaxError: Unexpected identifier in /Users/apple/Documents/NodeJS/views/index.ejs while compiling ejs

Collapse
 
justicebringer profile image
Gabriel

I believe you tried an include but you may have written it bad. Try to write it like this:

<%- include ("../fragments/header") %>

Collapse
 
siddm22 profile image
Siddhant Misra

Same error here. Any fix for this?

Collapse
 
hridoy100 profile image
Raihanul Alam Hridoy

Inside index.ejs file add this in line 1:
<%- include("partials/header") -%>