6

Getting this error in rails 6, in rails 5 it was a easy fix after updating the application to rails 6, including webpack this error is appear every where I try to close the model inside the js.erb files.

My files: pack/application.rb

require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")

import "bootstrap";
import "./src/application.scss";
import "jquery"

file pack/src/application.scss

@import "~bootstrap/scss/bootstrap";

file config/webpack/environment.js

   const { environment } = require('@rails/webpacker')

    const webpack = require('webpack')
    environment.plugins.prepend('Provide',
        new webpack.ProvidePlugin({
            $: 'jquery/src/jquery',
            jQuery: 'jquery/src/jquery'
        })
    )
    module.exports = environment
vidur punj
  • 5,019
  • 4
  • 46
  • 65

1 Answers1

0

The solution is here: [enter link description here][1] Change your environment.js to

environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
    $: 'jquery',
    jQuery: 'jquery'
})

)

Two Jquerys was being loaded twice, on [1]: https://discuss.rubyonrails.org/t/webpacker-bootstrap-jquery-what-am-i-doing-wrong-and-why-so-hard/77105/4?u=chibeepatag