Neil Carvalho

Desenvolvimento, lifehacks e outras coisas

Rails/Webpacker asset compilation error: SyntaxError> Unexpected token

26 Feb 2019

A colleague was having this problem today:

ExecJS::RuntimeError: SyntaxError: Unexpected token: operator (>) (line: 69370, col: 12, pos: 3058098)

It happened to be the file extension. The file was .js, so Asset Pipeline was trying to compile it. As the code had arrow functions (=>), introducted in EcmaScript 6, the code has to be in a ‘.es6’ file for webpacker to pick and compile to mundane javascript.


If you are using ES6 features, use the .es6 extension.

comments powered by Disqus