I have a npm project that uses jquery.
var $ = require(\'jquery\');
I also have an index html file that references bootstrap.
Assuming you want to install the latest version of Bootstrap 4, and that you are using node
10+ which uses npm
at least 5.6+ (I used it for node
v12.14.1 and npm
6.13.6, and it works properly):
npm install bootstrap
npm install jquery
npm install popper.js
Notice that you don't need to pass --save since after npm
5.0.0 installed modules are added as a dependency by default.
Now, assuming you have a file called index.html
at the same directory of node_modules
, you need to add the following to your head
tag:
You also need to add the following before
:
Notice the comment: jQuery first, then Popper.js, then Bootstrap JS. This is important since Bootstrap depends upon JQuery and Popper.js.