9

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:

//= 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.

Benoit Garret
  • 14,027
  • 4
  • 59
  • 64
asarig
  • 197
  • 2
  • 9
  • Which `application.js` file have you shown us the source of? Where is it located? – lloydpick Oct 24 '11 at 14:58
  • C:/Sites/MyApp/app/assets/javascripts/application.js the auto-generated one. I removed the three //require lines and it pre-compiled no problem, I have to assume that the jquery gems has a hiccup . I will eventually need jquery so it will be great to get this fixed. thx – asarig Oct 24 '11 at 15:19
  • Do you have jquery-rails in your Gemfile and you did bundle install? – bratsche Oct 24 '11 at 16:02
  • sure. here it is: group :assets do gem 'sass-rails', '~> 3.1.4' gem 'coffee-rails', '~> 3.1.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' – asarig Oct 24 '11 at 16:06

2 Answers2

13

Looks like it might be a problem with uglifier and Windows Script Host:

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

Make sure you're using the last version of uglifier (1.0.4). If you're still having problems, I'd suggest trying a different compiler (e.g. Closure compiler)

In Gemfile:

gem 'closure-compiler'

In config/environments/production.rb

config.assets.js_compressor = :closure

alternatively disable JS compression altogether:

config.assets.compress = false
Alex Peattie
  • 26,633
  • 5
  • 50
  • 52
  • thanks for this answer, it worked! to help others: I grabbed uglifier 1.0.4 and tried; no luck. Grabbed closure-compiler 1.1.4 , added the gem and the config changes and tried: worked like a charm! – asarig Oct 24 '11 at 16:46
  • Thank you. If the answer was helpful, please free to upvote and/or accept :) – Alex Peattie Oct 24 '11 at 16:59
  • Hi Alex, that was the first thing I tired to do, it tells me "vote up requires 15 reputation. I'm new here with a total of 1 reputation... so sorry, please don't stop helping me just because I can't say thank you properly! – asarig Oct 24 '11 at 22:41
1

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.

Straff
  • 5,499
  • 4
  • 33
  • 31