Skip to content

jQuery is not defined with Rails 5.1 and Yarn #924

@davidmccoy

Description

@davidmccoy

Hello! It seems like this gem isn't cooperating with Rails' move towards Wepback/Yarn and the fact that Rails 5.1 no longer includes jQuery by default.

Adding jQuery through Yarn with yarn add jquery results in the following error in the console:

Uncaught ReferenceError: jQuery is not defined

The only way to resolve this is to avoid packing jQuery with Yarn and manually including it in the pre-Rails 5.1 way. I had to add gem 'jquery-rails' back to my Gemfile and then require jquery/jquery_ujs in my app/assets/javascripts/application.js file. (//= require jquery //= require jquery_ujs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions