728x90
반응형

ejs를 2에서 3으로 업그레이드하고 나서 다음과 같은 에러가 발생했다.

SyntaxError: Unexpected identifier in index.ejs while compiling ejs

If the above error is not helpful, you may want to try EJS-Lint:
https://github.com/RyanZim/EJS-Lint
Or, if you meant to create an async function, pass `async: true` as an option.
    at new Function (<anonymous>)
    ...

에러 로그에서 어디에서 잘못됐는지 정확히 나오지도 않고

 

로그에서 나온 주소에서는 해결 방법을 찾을 수 없어 막막했다.

 

그래서 코드를 전부 제거하고 하나씩 찾아나가는 방법으로 어디가 문제인지를 찾았다.

 

원인은 include 하는 기존 방식이 제거돼서 에러가 발생했던 것이었다.

 

<% include ./header %>와 같이 돼있던 부분을 <%- include('header') %>와 같이 수정하면 된다.

 

참고 문헌

  1. https://github.com/mde/ejs/issues/476

반응형

+ Recent posts