# Erro do Uglifier durante a pré-compilação de assets

**URL:** <https://meta.discourse.org/t/uglifier-error-during-assets-precompile/96970>\
**Category:** Product Support\
**Tags:** unsupported-install\
**Created:** [11 Setembro , 2018 17:55 UTC](https://meta.discourse.org/t/uglifier-error-during-assets-precompile/96970 "2018-09-11T17:55:20Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![tmm1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tmm1/32/81412_2.png) [@tmm1](https://meta.discourse.org/u/tmm1)\
**Post date:** [11 Setembro , 2018 17:55 UTC](https://meta.discourse.org/t/uglifier-error-during-assets-precompile/96970/1 "2018-09-11T17:55:20Z")

</div>

I’m seeing some errors trying to run `rake assets:precompile` on 2.1.0 (stable branch), which appears to be due to the use of `const` in `vendor/assets/javascripts/caret_position.js` and `app/assets/javascripts/service-worker.js.erb`.

```plaintext
remote: 2018-09-11 02:38:12 +0000 Compressing: vendor-1d7e15932a900dc4b8be0306d85eb870358f859af13e8bd86e4b7fa9d859e1f1.js
remote: Compressing Javascript and Generating Source Maps
remote: rake aborted!
remote: Uglifier::Error: Unexpected token: keyword (const). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
remote: /tmp/build_d4c490df87465281635b6b03a0274f93/vendor/bundle/ruby/2.4.0/gems/uglifier-4.1.11/lib/uglifier.rb:234:in `parse_result'
remote: /tmp/build_d4c490df87465281635b6b03a0274f93/vendor/bundle/ruby/2.4.0/gems/uglifier-4.1.11/lib/uglifier.rb:216:in `run_uglifyjs'
remote: /tmp/build_d4c490df87465281635b6b03a0274f93/vendor/bundle/ruby/2.4.0/gems/uglifier-4.1.11/lib/uglifier.rb:178:in `compile_with_map'
remote: /tmp/build_d4c490df87465281635b6b03a0274f93/lib/tasks/assets.rake:103:in `compress_ruby'
remote: /tmp/build_d4c490df87465281635b6b03a0274f93/lib/tasks/assets.rake:150:in `compress'
remote: /tmp/build_d4c490df87465281635b6b03a0274f93/lib/tasks/assets.rake:190:in `block (4 levels) in <top (required)>'
remote: /tmp/build_d4c490df87465281635b6b03a0274f93/lib/tasks/assets.rake:160:in `block in concurrent?'
remote: /tmp/build_d4c490df87465281635b6b03a0274f93/lib/tasks/assets.rake:183:in `block (3 levels) in <top (required)>'
remote: /tmp/build_d4c490df87465281635b6b03a0274f93/lib/tasks/assets.rake:174:in `each'
remote: /tmp/build_d4c490df87465281635b6b03a0274f93/lib/tasks/assets.rake:174:in `block (2 levels) in <top (required)>'
remote: /tmp/build_d4c490df87465281635b6b03a0274f93/lib/tasks/assets.rake:160:in `concurrent?'
remote: /tmp/build_d4c490df87465281635b6b03a0274f93/lib/tasks/assets.rake:170:in `block in <top (required)>'
remote: /tmp/build_d4c490df87465281635b6b03a0274f93/vendor/bundle/ruby/2.4.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
remote: Tasks: TOP => assets:precompile
remote: (See full trace by running task with --trace)

```

It’s possible this something specific to my wacky environment (deploying to heroku), but I was able to resolve it using the fix suggested in the error:

```diff
diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake
index bdca7c30ed..847a8d07c2 100644
--- a/lib/tasks/assets.rake
+++ b/lib/tasks/assets.rake
@@ -95,6 +95,7 @@ def compress_ruby(from, to)
   data = File.read("#{assets_path}/#{from}")

   uglified, map = Uglifier.new(comments: :none,
+ harmony: true,
                                source_map: {
                                  filename: File.basename(from),
                                  output_filename: File.basename(to)

```

---

_[View the full topic](https://meta.discourse.org/t/uglifier-error-during-assets-precompile/96970)._
