I've been reading all over and I can't come to a conclusion of what's happening, I would appreciate some help. First than anything, this is my setup:
-
- views
- partials
header.ejs
app.js
...
app.use(express.static('public/css/'));
app.use(express.static('node_modules/bootstrap/dist/css/'));
that's feeding the header page in a ejs template:
<link rel="stylesheet" type="text/css" href="/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/YelpcampStyle.css">
Now... that above works like a champ, that's how I wrote it first, but I believe that's not a clean/best practice, so I'm trying to put it like this:
Express-js can't GET my static files, why?
app.use('/static', express.static(__dirname + '/public'));
and the code they gave does not work in my case, I tried and it can't find the bootstrap or the custom css. I tried:
app.use('public/css/', express.static(path.join(__dirname + 'node_modules/bootstrap/dist/css/')));
Now.. If I write this:
app.use('', express.static(path.join(__dirname + 'node_modules/bootstrap/dist/css/')));
It finds the bootstrap...
I also tried the above with the coma, instead of the + and still doesn't work. Also tried this one:
How to include scripts located inside the node_modules folder?
var path = require('path');
app.use('/scripts', express.static(path.join(__dirname, 'node_modules/bootstrap/dist')));
With no good result. Could someone point me to what I'm missing/doing wrong please.