简体   繁体   中英

Heroku ruby rails 4 with heroku ExecJS::ProgramError: Unexpected token: error

Hey guys im trying to deploy my ruby on rails 4 app on Heroku but having a problem on execution. Im using sqlite3 and I have tried everything.

This is the error on the last stage:

remote: -----> Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: rake aborted! remote: ExecJS::ProgramError: Unexpected token: operator (<<) (line: 16, col: 0, pos: 391) remote: Error remote: at new JS_Parse_Error (/tmp/execjs20150126-932-1636928js:2359:10623) remote: at js_error (/tmp/execjs20150126-932-1636928js:2359:10842) remote: at croak (/tmp/execjs20150126-932-1636928js:2359:19086) remote: at token_error (/tmp/execjs20150126-932-1636928js:2359:19223) remote: at unexpected (/tmp/execjs20150126-932-1636928js:2359:19311) remote: at expr_atom (/tmp/execjs20150126-932-1636928js:2359:27526) remote: at maybe_unary (/tmp/execjs20150126-932-1636928js:2359:30019) remote: at expr_ops (/tmp/execjs20150126-932-1636928js:2359:30777) remote: at maybe_conditional (/tmp/execjs20150126-932-1636928js:2359:30869) remote: at maybe_assign (/tmp/execjs20150126-932-1636928js:2359:31312) remote: (in /tmp/build_c9b90b740808f1b53c01e698e6740e18/app/assets/javascripts/app.js.orig)/tmp/build_c9b90b740808f1b53c01e698e6740e18/vendor/bundle/ruby/2.0.0/gems/execjs-2.2.2/lib/execjs/externa l_runtime.rb:64:in `extract_result' remote: /tmp/build_c9b90b740808f1b53c01e698e6740e18/vendor/bundle

my application.js:

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require jquery-ui

gemfile:

group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end

at the moment when I run this command:

 bundle exec rake --trace assets:precompile

I get:

** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile

But before I got something different which told me to go into public/assets/(a really long ass file name).js right next to the execution assets:precompile. When I went into the file, it did have a few "<<". It was generated by foundation I think but I dont wanna touch anything.

I was facing this issue as well. I found that multiline comments can cause this issue as well.

<!-- -->

This is a wrong syntax for multiline comments in js hence all the trouble.

These should be replaced with // comments

This fixed the issue for me.

And in order to find the issue, I had to run assets precompile task locally with development first, sprockets did not try to compress the file and it went through, then I could go to the line number to find the comment that was causing all the trouble.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM