In my project, I want to import Bootstrap, but it depends on jQuery.
require('jquery/dist/jquery.min');
require('bootstrap/dist/js/bootstrap.min');
When I use Webpack to handle this project, it causes an error:
Uncaught Error: Bootstrap's JavaScript requires jQuery
How can I specify jQuery for Bootstrap?
Replace your require
statement with the following:
window.jQuery = window.$ = require('jquery/dist/jquery.min');
require('!!script!jquery/dist/jquery.min.js');
The !!script!
is a special flag that will inline the script without using any loaders, equivalent to using a <script>
tag in HTML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With