0

I'm working on an Express + EJS project and getting this error when rendering my invoice.ejs view:

TypeError: C:\Users\naray\OneDrive\Desktop\Invoice-saas\invoice-generator\views\invoice.ejs:17
 >> 17|  <%- include('partials/sidebar', { user: user, page: 'invoice' }) %>
include is not a function

I’ve already installed EJS and configured it in my Express app:

app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));

My folder structure looks like this:

views/
 ├─ partials/
 │   └─ sidebar.ejs
 └─ invoice.ejs

I’m trying to include a sidebar partial and pass some variables (user, page) to it. However, EJS throws include is not a function. I’ve tried both syntaxes:

<%- include('partials/sidebar', { user: user, page: 'invoice' }) %>

and

<%- include('partials/sidebar') %>

but the error persists.

What could be causing this, and how can I properly include partials with variables in EJS?

2
  • Did you set filename option for EJS? Commented Oct 8 at 6:35
  • Are you using the word client? github.com/mde/ejs/issues/525 Commented Oct 10 at 21:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.