[英]RoR Precompiling Assets fail while rake assets:precompile - on basically empty application.js
運行:
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)
以下是application.js
的全部內容:
//= require jquery
//= require jquery_ujs
//= require_tree .
沒有別的。
我試圖從application.js
刪除三個//= require
行,然后預編譯運行沒有問題。
看起來它可能是uglifier和Windows Script Host的問題:
https://github.com/rails/rails/issues/2847
確保您使用的是最新版本的uglifier(1.0.4)。 如果你還有問題,我建議嘗試不同的編譯器(例如Closure編譯器)
在Gemfile
:
gem 'closure-compiler'
在config/environments/production.rb
config.assets.js_compressor = :closure
或者完全禁用JS壓縮:
config.assets.compress = false
我有同樣的錯誤
...>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='
...
並做到了
bundle update
引進來的
uglifier (2.1.1)
(除其他外),然后:
rake assets:precompile
這解決了我的問題。 Windows,Rails 3.2.11。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.