question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uglifier::Error: Unexpected token: punc ((). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true)

See original GitHub issue

Hi, When I run “rake assets:precompile RAILS_ENV=production” command, I have issue. rake assets:precompile RAILS_ENV=production rake aborted! Uglifier::Error: Unexpected token: punc ((). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true). /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/uglifier-4.0.2/lib/uglifier.rb:237:in parse_result' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/uglifier-4.0.2/lib/uglifier.rb:219:in run_uglifyjs’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/uglifier-4.0.2/lib/uglifier.rb:169:in compile' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:53:in call’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:28:in call' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in call_processor’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in block in call_processors' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in reverse_each’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in call_processors' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in load_from_unloaded’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in block in load' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in fetch_asset_from_dependency_cache’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in load' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in block in initialize’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in load' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in find_asset’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/base.rb:73:in find_all_linked_assets' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:142:in block in find’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:114:in block (2 levels) in logical_paths' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:228:in block in stat_tree’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in block in stat_directory' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in each’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in stat_directory' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in stat_tree’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in each' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in block in logical_paths’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in each' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in logical_paths’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:140:in find' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in compile’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in block (3 levels) in define' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in with_logger’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in block (2 levels) in define' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/gems/rake-12.2.1/exe/rake:27:in <top (required)>’ /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/bin/ruby_executable_hooks:15:in eval' /Users/leonverspeek/.rvm/gems/ruby-2.3.1@zombie/bin/ruby_executable_hooks:15:in <main>’ Tasks: TOP => assets:precompile (See full trace by running task with --trace)

How to fix this issue?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:41
  • Comments:31 (1 by maintainers)

github_iconTop GitHub Comments

1277reactions
abrahamcommented, Dec 17, 2017

Try replacing

config.assets.js_compressor = :uglifier

with

config.assets.js_compressor = Uglifier.new(harmony: true)

in config/environments/production.rb

77reactions
chengs2416mecommented, Jan 4, 2018

abraham, you save my day

Read more comments on GitHub >

github_iconTop Results From Across the Web

ES6 syntax, harmony mode must be enabled with Uglifier.new ...
Uglifier ::Error: Unexpected token: keyword (const). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true). while ...
Read more >
README — Documentation for uglifier (4.2.0) - RubyDoc.info
Uglifier ::Error: Unexpected token: punc ((). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true). The experimental ES6 ......
Read more >
Uglifier::Error: Unexpected token: punc ((). To use ES6 syntax ...
Uglifier ::Error: Unexpected token: punc ((). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true)
Read more >
Rails 5 -> 6 Upgrade: ES6 Uglifier bug - Mintbit
ActionView::Template::Error (Unexpected token: keyword (const). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony ...
Read more >
Uglifier error during assets precompile - Discourse Meta
... remote: Uglifier::Error: Unexpected token: keyword (const). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true). remote: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found