Ruby on rails Rails bower不';不编译
我的rails解决方案使用Bower来管理前端库。 我跟着去安装它。 它正在工作,但当我尝试预编译时,它会出现以下错误:Ruby on rails Rails bower不';不编译,ruby-on-rails,ruby,ruby-on-rails-4,assets,bower,Ruby On Rails,Ruby,Ruby On Rails 4,Assets,Bower,我的rails解决方案使用Bower来管理前端库。 我跟着去安装它。 它正在工作,但当我尝试预编译时,它会出现以下错误: 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
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)
知道怎么修吗
提前感谢 我也有同样的问题。。我发现这是因为资产的压缩。。因此,一个临时修复程序将在config/environments/production.rb中对此行进行注释:
config.assets.js_compressor = :uglifier
我目前不知道是uglifier本身在压缩JS文件后导致了错误,还是JS有什么问题。我目前正在探索js压缩的其他替代方案,看看它是否有效。。另外,我还使用了bower组件,因此可能是bower+uglifier导致了错误
我能够通过编辑intro.js文件来修复此问题。产生错误的行是:
}(typeof window !== "undefined" ? window : this, function( window, noGlobal ){
换成
}(typeof window !== "undefined" ? window : this, function( window, noGlobal ){}));
您现在可能会得到outro.js的错误,它只包含缺少的
}));
只要把它删除,所有的东西都应该编译。我没有对它进行过广泛的测试,但我没有注意到jquery因为这些变化而出现任何中断。在
/home/augustopedraza/Documents/Projects/BuscoHogar/landing page/vendor/assets/bower_components/jquery/src/intro.js
的第46行有什么内容?这是bower在运行后下载的jquery代码:rake>bower:install
这是个坏主意,因为intro.js和outro.js是包装器,而不是独立的js文件,这样做应该会破坏一些东西。资料来源:是的,我对这句话进行了评论,你有没有找到一个合适的修复方法或替代的丑八怪?