简体   繁体   English

rake预编译资产在rake资产时失败:预编译 - 基本上是空的application.js

[英]RoR Precompiling Assets fail while rake assets:precompile - on basically empty application.js

Running: 运行:

bundle exec rake assets:precompile RAILS_ENV=production --trace

** Execute assets:precompile:primary
rake aborted!
TypeError: Object doesn't support this property or method
  (in C:/Sites/MyApp/app/assets/javascripts/application.js)

Here is the entire content of application.js : 以下是application.js的全部内容:

//= require jquery
//= require jquery_ujs
//= require_tree .

nothing else there. 没有别的。

I tried to remove the three //= require lines from application.js , the precompilation then runs with no problems. 我试图从application.js删除三个//= require行,然后预编译运行没有问题。

Looks like it might be a problem with uglifier and Windows Script Host: 看起来它可能是uglifier和Windows Script Host的问题:

https://github.com/rails/rails/issues/2847 https://github.com/rails/rails/issues/2847

Make sure you're using the last version of uglifier (1.0.4). 确保您使用的是最新版本的uglifier(1.0.4)。 If you're still having problems, I'd suggest trying a different compiler (eg Closure compiler) 如果你还有问题,我建议尝试不同的编译器(例如Closure编译器)

In Gemfile : Gemfile

gem 'closure-compiler'

In config/environments/production.rb config/environments/production.rb

config.assets.js_compressor = :closure

alternatively disable JS compression altogether: 或者完全禁用JS压缩:

config.assets.compress = false

I got same sort of error 我有同样的错误

...>rake assets:precompile
C:/Ruby192/bin/ruby.exe C:/Ruby192/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
...
rake aborted!
TypeError: Object doesn't support this property or method
  (in C:/Users/straffordw/railsApps/chorus-spp/app/assets/javascripts/application.js)
C:/Ruby192/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:68:in `extract_result'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:28:in `block in exec'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:41:in `compile_to_tempfile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:27:in `exec'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/uglifier-2.0.1/lib/uglifier.rb:167:in `really_compile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/uglifier-2.0.1/lib/uglifier.rb:95:in `compile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.2.11/lib/sprockets/compressors.rb:74:in `compress'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/processing.rb:265:in `block in js_compressor='
...

and did 并做到了

bundle update

which brought in 引进来的

uglifier (2.1.1)

(amongst other things), then: (除其他外),然后:

rake assets:precompile

and that resolved my problem. 这解决了我的问题。 Windows, Rails 3.2.11. Windows,Rails 3.2.11。

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

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