12

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?

AstroCB
  • 11,800
  • 20
  • 54
  • 68
zq010
  • 173
  • 1
  • 8

2 Answers2

22

Replace your require statement with the following:

window.jQuery = window.$ = require('jquery/dist/jquery.min');

Dave
  • 35
  • 6
5
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.

Varun Mulloli
  • 628
  • 12
  • 28