Friday, April 13, 2018

ExecJS::RuntimeError: SyntaxError: Unexpected token punc «(», expected punc «:»


I got this error when deploy Rails app to production server.
This error will be raised if your javasctripts on assets include ES6 syntax.

These steps will fix the probrem.

  1. Update uglifier
    bundle update uglifier
  2. Modify config/environments/production.rb
    from
    config.assets.js_compressor = :uglifier
    to
    config.assets.js_compressor = Uglifier.new(harmony: true)


https://github.com/lautis/uglifier/issues/116#issuecomment-347386669