2011-10-24 94 views
9

运行:RoR的预编译资产失败而耙资产:预编译 - 对基本清空的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行,预编译然后运行没有问题。

+0

哪个'application.js'文件给我们看过源代码?它位于哪里? – lloydpick

+0

C:/Sites/MyApp/app/assets/javascripts/application.js是自动生成的。我删除了三个// require行,它预编译没有问题,我必须假设jquery gems有一个呃逆。我最终会需要jquery,所以这将是很好的得到这个固定的。 thx – asarig

+0

你的Gemfile中是否有jquery-rails,并且你是否安装了bundle? – bratsche

回答

13

看起来它可能与uglifier和Windows脚本宿主的一个问题:

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 
+0

感谢您的回答,它的工作!帮助别人:我抓住了uglifier 1.0.4并尝试过;没有运气。抓住关闭编译器1.1.4,添加了宝石和配置变化,并尝试:像一个魅力工作! – asarig

+0

谢谢。如果答案是有帮助的,请随时upvote和/或接受:) –

+0

嗨亚历克斯,这是我第一件事累了做,它告诉我“投票上来需要15声望。我在这里是新的总共1声望...很抱歉,请不要停止帮助我,因为我无法正确地说声谢谢! – asarig

1

我得到了同样的排序呃ROR

...>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。