运行:
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 .
那里别的什么都没有。
我尝试从//= require
删除三个application.js
行,预编译然后运行没有问题。
答案 0 :(得分:13)
看起来它可能是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
答案 1 :(得分:1)
我遇到了同样的错误
...>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。