简体   繁体   中英

when I run rake assets:precompile got couldn't find file 'jquery' in application.js on //= require jquery

when I run

bundle exec rake assets:precompile 

I got

couldn't find file 'jquery'  

in application.js on line:

//= require jquery

Rails 3.2.2. What is reason?

I'd venture to say you don't have a jquery.js file anywhere in your app. If it's not in app/assets or vendor/assets or lib/assets, add it to one of them -- or if you are using the jquery-rails gem, follow the instructions here .

If you're running in production you must comment out the line

Bundler.require(*Rails.groups(:assets => %w(development test)))

and uncomment the following

Bundler.require(:default, :assets, Rails.env)

since by default gems included in the "assets" group specified in the Gemfile won't be added in the production environment.

This lead me to a similar situation in which I was running a precompile in production but Uglifier kept throwing me a "couldn't find jquery error" but clean compile in development.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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