Rails 5 Heroku deploy error: ExecJS::ProgramError: SyntaxError: Unexpected token: name (autoRegisterNamespace)
It may have something to do with javascript/coffescript syntax. Check if you have let
, it shout be replaced with var
.
Edit - see @Guilherme Lages Santos's response. Uglifier added ES6 support since version 3.2.0 so you can just use it like this in your environment file
config.assets.js_compressor = Uglifier.new(harmony: true)
As the Uglifier official documentation says (https://github.com/lautis/uglifier):
"The experimental ES6 syntax support can be enabled by passing :harmony => true option to Uglifier."
Uglifier.compile(js, harmony: true)
So replace in config/environments/production.rb
.
config.assets.js_compressor = :uglifier
with
config.assets.js_compressor = Uglifier.new(harmony: true)
I also had this issue.
It's important to remember that by default Heroku is precompiling in a production environment. When you run rake assets:precompile
locally it's typically a development environment, which for me didn't exhibit the issue.
So in order to reproduce the issue locally, try
RAILS_ENV=production rake assets:precompile --trace