NodeJs - esc is not a function

Dash picture Dash · Mar 9, 2017 · Viewed 7.1k times · Source

I got a weird issues when trying to render an .ejs file at this specific lines

TypeError: /home/me/nodeapp/app/views/default/page/connection.ejs:66
        64|         <div class="col s12 l8">
        65|             <ul class="collapsible popout" data-collapsible="accordion"">
     >> 66|                 <%- include ../api_html/connection/connection_list.ejs %>
        67|             </ul>
        68|         </div>

Here is the error

esc is not a function

I really don't understand from where this error is coming from. I'm not using an esc function the ../api_html/connection/connection_list.ejs file which is included.

In addition to this, I'm not having this issue my local server (under Windows), this error is fired under a CentOs server where I run the exactly same nodeapp.

Any ideas would be very appreciated !

Thanks!

Answer

Dash picture Dash · Mar 10, 2017

First thanks for your answers.

I figured out the issue.

The error was in the included EJS file<%- include ('../api_html/connection/connection_list.ejs') %>.

For example, if you include <% include ../partials/header %> that contains <%= user.email %>, it will work perfectly when the user is defined (user is logged in) but will throw esc in not a function when it's not.