title: Getting an Uncaught ReferenceError: jQuery is not defined in Rails 6 project
body: <p>I've been working on migrating a legacy Rails app to using webpacker in Rails 6.0.2, but keep coming across an <code>Uncaught ReferenceError: jQuery is not defined</code> error. This same error appears even in a fresh Rails 6 app that I create. </p>
  
  <p>I've followed plenty of different tutorials / StackOverflow answers, but nothing seems to be working. Here's what I currently have - can anyone please point me in the right direction?</p>
  
  <p>I've run <code>yarn add jquery</code> so this is in my <code>package.json</code> file:</p>
  
  <pre><code>{
    "name": "test_app",
    "private": true,
    "dependencies": {
      "@rails/actioncable": "^6.0.0",
      "@rails/activestorage": "^6.0.0",
      "@rails/ujs": "^6.0.0",
      "@rails/webpacker": "4.2.2",
      "bootstrap": "^4.4.1",
      "jquery": "^3.5.0",
      "popper.js": "^1.16.1",
      "turbolinks": "^5.2.0"
    },
    "version": "0.1.0",
    "devDependencies": {
      "webpack-dev-server": "^3.10.3"
    }
  }
  </code></pre>
  
  <p>In my <code>application.js</code> file:</p>
  
  <pre><code>require("@rails/ujs").start()
  require("turbolinks").start()
  require("@rails/activestorage").start()
  require("channels")
  require("jquery") // I've also tried without this line.
  require("bootstrap");
  </code></pre>
  
  <p>And in my <code>environment.js</code> file:</p>
  
  <pre><code>const { environment } = require('@rails/webpacker')
  var webpack = require('webpack');
  
  environment.plugins.append('Provide', new webpack.ProvidePlugin({
    $: 'jquery/src/jquery', // I've also tried with just 'jquery' rather than referring specifically to the src folder.
    jQuery: 'jquery/src/jquery' // Same comment as above.
  }));
  
  module.exports = environment
  </code></pre>
  
  <p>I'm pretty baffled as to why it's not working - I've tried the solutions suggested <a href="https://stackoverflow.com/questions/54905026/how-to-add-jquery-third-party-plugin-in-rails-6-webpacker">here</a>, as well as a multitude of other resources. Any help would be greatly appreciated!</p>