Ruby-on-rails – Precompiling assets failed ExecJS::ProgramError: Unexpected token: operator (=) (line: 10770 , col: 0, pos: 300859)

githerokurubyruby-on-rails

I am having issues pushing my rails project to heroku. I get a "Precompiling assets failed" message . I am new to programming and new to ruby on rails. I really need some help. Here is the text from my command line.

 $ git push heroku master
Counting objects: 76, done.
Compressing objects: 100% (63/63), done.
Writing objects: 100% (76/76), 27.38 KiB | 11.00 KiB/s, done.
Total 76 (delta 4), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.0.0
remote: ###### WARNING:
remote:        Removing `Gemfile.lock` because it was generated on Windows.
remote:        Bundler will do a full resolve so native gems are handled properl
y.
remote:        This may result in unexpected gem versions being used in your app
.
remote:        In rare occasions Bundler may not be able to resolve your depende
ncies at all.
remote:        https://devcenter.heroku.com/articles/bundler-windows-gemfile
remote:
remote: -----> Installing dependencies using 1.9.7
remote:        Running: bundle install --without development:test --path vendor/
bundle --binstubs vendor/bundle/bin -j4
remote:        Fetching gem metadata from https://rubygems.org/............
remote:        Fetching version metadata from https://rubygems.org/...
remote:        Fetching dependency metadata from https://rubygems.org/..
remote:        Resolving dependencies....
remote:        Rubygems 2.0.14 is not threadsafe, so your gems must be installed
 one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem insta
llation.
remote:        Installing rake 10.4.2
remote:        Installing i18n 0.7.0
remote:        Installing multi_json 1.11.0
remote:        Installing activesupport 3.2.21
remote:        Installing builder 3.0.4
remote:        Installing activemodel 3.2.21
remote:        Installing erubis 2.7.0
remote:        Installing journey 1.0.4
remote:        Installing rack 1.4.5
remote:        Installing rack-cache 1.2
remote:        Installing rack-test 0.6.3
remote:        Installing hike 1.2.3
remote:        Installing tilt 1.4.1
remote:        Installing sprockets 2.2.3
remote:        Installing actionpack 3.2.21
remote:        Installing mime-types 1.25.1
remote:        Installing polyglot 0.3.5
remote:        Installing treetop 1.4.15
remote:        Installing mail 2.5.4
remote:        Installing actionmailer 3.2.21
remote:        Installing arel 3.0.3
remote:        Installing tzinfo 0.3.44
remote:        Installing activerecord 3.2.21
remote:        Installing activeresource 3.2.21
remote:        Using bundler 1.9.7
remote:        Installing coffee-script-source 1.9.1.1
remote:        Installing execjs 2.5.2
remote:        Installing coffee-script 2.4.1
remote:        Installing rack-ssl 1.3.4
remote:        Installing json 1.8.2
remote:        Installing rdoc 3.12.2
remote:        Installing thor 0.19.1
remote:        Installing railties 3.2.21
remote:        Installing coffee-rails 3.2.2
remote:        Installing jquery-rails 3.1.2
remote:        Installing pg 0.18.2
remote:        Installing rails 3.2.21
remote:        Installing sass 3.4.14
remote:        Installing sass-rails 3.2.6
remote:        Installing uglifier 2.7.1
remote:        Bundle complete! 6 Gemfile dependencies, 40 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into ./vendor/bundle.
remote:        Post-install message from rdoc:
remote:        Depending on your version of ruby, you may need to install ruby r
doc/ri data:
remote:        <= 1.8.6 : unsupported
remote:        = 1.8.7 : gem install rdoc-data; rdoc-data --install
remote:        = 1.9.1 : gem install rdoc-data; rdoc-data --install
remote:        >= 1.9.2 : nothing to do! Yay!
remote:        Bundle completed (54.39s)
remote:        Cleaning up the bundler cache.
remote: -----> Writing config/database.yml to read from DATABASE_URL
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/p
lugins! Support for these plugins will be removed in Rails 4.0. Move them out an
d bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and
 config/initializers/myplugin.rb. See the release notes for more on this: http:/
/weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from
 <top (required)> at /tmp/build_7f6590528210ec3b45a43e69c0119446/Rakefile:7)
remote:        DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/p
lugins! Support for these plugins will be removed in Rails 4.0. Move them out an
d bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and
 config/initializers/myplugin.rb. See the release notes for more on this: http:/
/weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from
 <top (required)> at /tmp/build_7f6590528210ec3b45a43e69c0119446/Rakefile:7)
remote:        rake aborted!
remote:        ExecJS::ProgramError: Unexpected token: operator (=) (line: 10770
, col: 0, pos: 300859)
remote:        Error
remote:        at new JS_Parse_Error (/tmp/execjs20150523-743-1p3uckwjs:2359:106
23)
remote:        at js_error (/tmp/execjs20150523-743-1p3uckwjs:2359:10842)
remote:        at croak (/tmp/execjs20150523-743-1p3uckwjs:2359:19086)
remote:        at token_error (/tmp/execjs20150523-743-1p3uckwjs:2359:19223)
remote:        at unexpected (/tmp/execjs20150523-743-1p3uckwjs:2359:19311)
remote:        at expr_atom (/tmp/execjs20150523-743-1p3uckwjs:2359:27526)
remote:        at maybe_unary (/tmp/execjs20150523-743-1p3uckwjs:2359:30019)
remote:        at expr_ops (/tmp/execjs20150523-743-1p3uckwjs:2359:30777)
remote:        at maybe_conditional (/tmp/execjs20150523-743-1p3uckwjs:2359:3086
9)
remote:        at maybe_assign (/tmp/execjs20150523-743-1p3uckwjs:2359:31312)
remote:        at expression (/tmp/execjs20150523-743-1p3uckwjs:2359:31625)
remote:        at simple_statement (/tmp/execjs20150523-743-1p3uckwjs:2359:22563
)
remote:        at /tmp/execjs20150523-743-1p3uckwjs:2359:20468
remote:        (in /tmp/build_7f6590528210ec3b45a43e69c0119446/app/assets/javasc
ripts/application.js)new JS_Parse_Error ((execjs):2359:10623)
remote:        js_error ((execjs):2359:10842)
remote:        croak ((execjs):2359:19086)
remote:        token_error ((execjs):2359:19223)
remote:        unexpected ((execjs):2359:19311)
remote:        expr_atom ((execjs):2359:27526)
remote:        maybe_unary ((execjs):2359:30019)
remote:        expr_ops ((execjs):2359:30777)
remote:        maybe_conditional ((execjs):2359:30869)
remote:        maybe_assign ((execjs):2359:31312)
remote:        expression ((execjs):2359:31625)
remote:        simple_statement ((execjs):2359:22563)
remote:        (execjs):2359:20468
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/execjs-2.5.2/lib/execjs/external_runtime.rb:39:in `exec'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/execjs-2.5.2/lib/execjs/external_runtime.rb:21:in `eval'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/execjs-2.5.2/lib/execjs/external_runtime.rb:46:in `call'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/uglifier-2.7.1/lib/uglifier.rb:212:in `run_uglifyjs'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/uglifier-2.7.1/lib/uglifier.rb:179:in `compile'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/actionpack-3.2.21/lib/sprockets/compressors.rb:74:in `compress'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/processing.rb:265:in `block in js_compres
sor='
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/processor.rb:29:in `call'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/processor.rb:29:in `evaluate'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/context.rb:193:in `block in evaluate'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/context.rb:190:in `each'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/context.rb:190:in `evaluate'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/bundled_asset.rb:26:in `initialize'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/base.rb:252:in `new'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/base.rb:252:in `build_asset'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/index.rb:93:in `block in build_asset'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/caching.rb:19:in `cache_asset'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/index.rb:92:in `build_asset'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/base.rb:169:in `find_asset'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/index.rb:60:in `find_asset'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/actionpack-3.2.21/lib/sprockets/static_compiler.rb:19:in `block in comp
ile'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/base.rb:219:in `block in each_logical_pat
h'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/base.rb:206:in `block (2 levels) in each_
file'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/base.rb:196:in `each'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/base.rb:196:in `each_entry'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/base.rb:204:in `block in each_file'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/base.rb:203:in `each'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/base.rb:203:in `each_file'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/sprockets-2.2.3/lib/sprockets/base.rb:217:in `each_logical_path'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/actionpack-3.2.21/lib/sprockets/static_compiler.rb:18:in `compile'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/actionpack-3.2.21/lib/sprockets/assets.rake:56:in `internal_precompile'

remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/actionpack-3.2.21/lib/sprockets/assets.rake:70:in `block (3 levels) in
<top (required)>'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/actionpack-3.2.21/lib/sprockets/assets.rake:60:in `block (3 levels) in
<top (required)>'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/actionpack-3.2.21/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rak
e_task'
remote:        /tmp/build_7f6590528210ec3b45a43e69c0119446/vendor/bundle/ruby/2.
0.0/gems/actionpack-3.2.21/lib/sprockets/assets.rake:29:in `block (2 levels) in
<top (required)>'
remote:        Tasks: TOP => assets:precompile:primary
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:
remote:  !     Push rejected, failed to compile Ruby app
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to whispering-chamber-4883.
remote:
To https://git.heroku.com/whispering-chamber-4883.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/whispering-chamber-48
83.git'

Thanks.

Best Solution

You probably already solved this by now, but I stumbled across this issue and wanted to share my solution.

As an answer above suggested, the best way to track the error down to the problematic file is to run

rake assets:precompile RAILS_ENV=production

locally while excluding files or directories you might think contain the problem. I deleted directories one by one (which I could later checkout again from my repo) until I got the precompilation running. I then drilled down into the last deleted directory and tracked it down to a certain file and a function of the form

array.find(name => name.id === user_id);

My research showed that it turns out the largest update to Javascript (ES5) was released in 2009 and since then, only unitl June 2015 was the ECMAScript 6 (ES6) final specification released. The syntax used in this function is supported by ES6 but not ES5 and ES6 is not yet supported on Rails (I was running RoR 5.0.0.1), at least not with ExecJS on the assets pipeline.

What you CAN do, is change your function to an alternative syntax, namely

array.find(function(name){return name.id === user_id});

and it should work equivalently.

  • More on the find function here
  • To get ES6 working on RoR, you might want to check out Babel, as described here
Related Question