简体   繁体   中英

Rails bower doesn't compile

I have my rails solution using Bower to manage my frontend libraries. I followed this tutorial to setup it. It's working, but when I try to precompile this, it blows up with the following error:

RAILS_ENV=production bundle exec rake assets:precompile
rake aborted!
ExecJS::ProgramError: Unexpected token: eof (undefined) (line: 46, col: 0, pos: 1406)

Error
    at new JS_Parse_Error (/tmp/execjs20140911-20410-llghcjjs:2357:10623)
    at js_error (/tmp/execjs20140911-20410-llghcjjs:2357:10842)
    at croak (/tmp/execjs20140911-20410-llghcjjs:2357:19067)
    at token_error (/tmp/execjs20140911-20410-llghcjjs:2357:19204)
    at unexpected (/tmp/execjs20140911-20410-llghcjjs:2357:19292)
    at block_ (/tmp/execjs20140911-20410-llghcjjs:2357:24537)
    at ctor.body (/tmp/execjs20140911-20410-llghcjjs:2357:24191)
    at function_ (/tmp/execjs20140911-20410-llghcjjs:2357:24256)
    at expr_atom (/tmp/execjs20140911-20410-llghcjjs:2357:27308)
    at maybe_unary (/tmp/execjs20140911-20410-llghcjjs:2357:29977)
  (in /home/augustopedraza/Documents/Projects/BuscoHogar/landing-page/vendor/assets/bower_components/jquery/src/intro.js)

Any idea how to fix it?

Thanks in advance!!!

I had the same problem.. I figured out it was because of the compression of the assets generally.. So a temporary fix will be commenting this line in config/environments/production.rb:

config.assets.js_compressor = :uglifier

I currently don't know if uglifier itself causes the error after compressing the JS files or if the JS has something wrong. I'm currently exploring other alternatives for js compression to see if it'll work.. PS I'm also using bower components so maybe bower + uglifier causes the error

I was able to fix this by editing the file intro.js The line producing the error is:

 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ){

change it to

}(typeof window !== "undefined" ? window : this, function( window, noGlobal ){}));

You will probably now get the error for outro.js, which only contains the missing

}));

Just delete it out and everything should compile. I haven't extensively tested it but I haven't noticed anything with jquery breaking because of these changes.

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