Skip to content
← Back to Community
My Node.js website's stylesheet = null
Profile icon
RixTheTyrunt

Hello, I didn't found the styleshet, while I defined the stylesheet in style.css file, but when I try to find it in my website, it shows monospaced element like this:

Cannot GET /style.css

Can you help?

Voters
Profile icon
RixTheTyrunt
Comments
hotnewtop
Profile icon
RixTheTyrunt

Maybe making style attributes will work?

Profile icon
RixTheTyrunt

Yes! Finally!

Profile icon
Coder100

you have a static folder that's correct
but you need to host that static folder.

app.use(express.static(__dirname + "/static"));

add that after the const app = express();

Also, have you considered using res.sendFile() instead of copying and pasting your HTML files??

Profile icon
RixTheTyrunt

Still nothing.

Profile icon
Coder100

you didn't add the code lol @RixTheTyrunt

Profile icon
RixTheTyrunt

I actually added, but it didn't work.

Profile icon
RixTheTyrunt

I tried res.sendFile("https://nodejam.rixthetyrunt.repl.co/index.html") but I didn't get anything...

Profile icon
Coder100

no that's not what I meant

res.sendFile(__dirname + "/index.html")

now make an index.html in the root directory (not in any folders.)
@RixTheTyrunt

Profile icon
RixTheTyrunt

What is __dirname?

Profile icon
Coder100

the current director you are in @RixTheTyrunt

Profile icon
ch1ck3n

you should put it in /static

Profile icon
RixTheTyrunt

I will put the stylesheet in the folder named static. OK?

Profile icon
RixTheTyrunt

Do I understand you?

Profile icon
RixTheTyrunt

Still no stylesheet. Yet.

Profile icon
ch1ck3n

@RixTheTyrunt you dont fricking need to spam my notification to get your point across