'Node.js EJS Include feature is not working in my case

I want to include header.ejs and footer.ejs into order.ejs. The image below my folder structure.

enter image description here

But, I've got error. The code related to include in order.ejs is written below.

/// order.ejs

<%- include('../common/header.ejs') %>

I think my code is wrong. But I could not find any solution.

Thanks in advance.

Add Error Message

Error: ejs:18
    16|                         <tr>
    17|                             <td align="center" valign="top">
 >> 18|                                 <%- include('../common/header.ejs') %>
    19|                             </td>
    20|                         </tr>
    21|                         <tr>

Could not find the include file "../common/header.ejs" {"timestamp":"2022-05-14 13:58:57"}


Solution 1:[1]

I have solved this issue. The problem was not a template, but the EJS function.

OLD Function:

ejs.compile()

NEW Function:

ejs.renderFile()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tyler2P