简体   繁体   English

Rails Bower无法编译

[英]Rails bower doesn't compile

I have my rails solution using Bower to manage my frontend libraries. 我有使用Bower来管理前端库的rails解决方案。 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 / 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. 我目前不知道uglifier本身在压缩JS文件后是否会导致错误,或者JS是否有问题。 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 我目前正在探索js压缩的其他替代方案,以查看它是否可以正常工作。.PS我也在使用Bower组件,因此也许bower + uglifier会导致错误

I was able to fix this by editing the file intro.js The line producing the error is: 我可以通过编辑文件intro.js来解决此问题。产生错误的行是:

 }(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 您现在可能会得到outro.js的错误,该错误仅包含缺少的内容

}));

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. 我还没有对其进行广泛的测试,但是由于这些更改,我没有注意到jquery有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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