Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Bootstrap with npm and Node.js

I'm having a difficult time understanding where/how to use Bootstrap in my nodejs project. I installed Bootstrap with npm, but how do I include it in my index.html file?

Do I need to include the stylesheet tag at the top and the tags above the tag at the bottom like usual in my .html files, or can I just start applying Bootstrap classes to my elements once I've required it in my app.js file?

Also, is there an advantage to using npm to install Bootstrap versus using the CDNs?

like image 764
krfisc Avatar asked Jul 15 '26 02:07

krfisc


1 Answers

Add this code if using server like Express

app.use(
  express.static(path.join(__dirname, "node_modules/bootstrap/dist/"))
);

Then in your head tag:

  <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
like image 114
Panda Avatar answered Jul 21 '26 12:07

Panda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!