I'm developing an aplication using nodejs and the framework Express.
I want to add Bootstrap to my project in local.
I added this to my index <head>
<script language="javascript" src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css"/>
I found that I have to add this code to my app.js
app.use(express.static(__dirname + '../node_modules/bootstrap/dist'));
but it doesn't works too. (I have in mind the path of the Bootstrap and use '../modules...' too)
You can try this as well, worked for me.
Install bootstrap
npm install bootstrap@3
Now in app.js file add the following code:
app.use('/css', express.static(__dirname + '/node_modules/bootstrap/dist/css'));
Use bootstrap.css in your layout or any other file
<link rel="stylesheet" href="/css/bootstrap.min.css" />
Make sure the path you have provided is correct.
I hope this will work :)
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