0

My project structure

index.js
views
   ------partials
             --------login
             --------footer
   ------pages
            ---------index

Now i am rendering index.ejs via

res.render('pages/index',{template:'../partials/login'})}

In index.ejs i have

<% include (template) %>

I get this error Error: Could not find include include file.

I have view cache set to false. These are my project dependencies

"dependencies": {
"ejs": "^2.5.7",
"express": "^4.16.3",
"express-generator": "^4.16.0"}

I tried giving abosulte path didn't work. Any suggestions?

Rahul Padalkar
  • 125
  • 1
  • 11
  • 1
    Possible duplicate of [Could not find include include file](https://stackoverflow.com/questions/46309842/could-not-find-include-include-file) – Aaron Rumery Mar 24 '18 at 19:56

1 Answers1

-1

The problem I think, is that you are including template as a string, and you are putting it in brackets. Try it like this:

<% include ../partials/login %>

What I think it is reading it as is:

<% include ('../partials/login') %>

Try that. I'm pretty sure it will work, because you have the most updated versions of your dependencies. Please tell me if that helped.