I installed bootstrap with npm and now I have a bunch of .js files but there is no “master” js file that I can import into html, unlike the css file that does have a master .css file.
I was unable to get the collapse to work without a cdn with
<script src="./node_modules/bootstrap/js/dist/collapse.js"></script> <script src="./node_modules/bootstrap/js/dist/button.js"></script>
But It did work with:
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.min.js" integrity="sha384-pQQkAEnwaBkjpqZ8RU1fF1AKtTcHJwFl3pblpTlHXybJjHpMYo79HY3hIi4NKxyj" crossorigin="anonymous"></script>
This is my collapse menu:
<div class="container"> <div class="col col-sm-2"> <a class="" data-bs-toggle="collapse" href="#started" role="button">Getting Started</a> <div id="started" class="collapse">Hi</div> </div> <div class="col col-md-8"> </div> <div class="col col-lg-2"></div> </div>
I’d prefer not to use the cdn because I’m already using the node_modules from the css and sass. Am I missing scripts to import? Or is there a way to easily import all of the scripts without manually doing it?
Advertisement
Answer
I found the bootstrap.min.js file thanks to ISAE.
I downloaded the bootstrap file here: https://www.npmjs.com/package/bootstrap#whats-included and went into bootstrap/dist/js/
which has all of the master bootstrap files.
You can also use npm install bootstrap
and the pathway is very similar: node_modules/bootstrap/dist/js/