Learn to Code via Tutorials on Repl.it!

← Back to all posts
This could be worth your time? I don't know...is it? Check it out so you can know
h
Whippingdot

Bruhter ok something is wrong with me...

WRITE INTO DA Q

So I am going to create a bug report about this later but for now I am going to teach you how to work your way around a common issue for nodejs(express only i think) users on replit:

  • linking

Linking is so BAD on replit for nodejs. I think that is actually nodejs's problem but if replit wants to make it easier for developers, they really need to fix this problem. So basically you cannot use relative linking or any type of linking really to link images, CSS files, JS files, or anything when you create a nodejs repl. For some reason it just doesn't link - no one nows why (someone probably dos). The way most people fix this is by using some Static file method, which seems a little complex. The one method that works for me and that is easy to understand is the method you can use when you use expressjs. ExpressJS is the Javascript library or wutever you use whenever you do routing with your website. That means when you make it so like '/style' goes to a part of your website etc. You can route a part of your website to give off a file:

What the above code did was make the '/style' part of your website (like daf.repl.co/style) send you to the code of your style.css file. Then when you link in HTML, you just have to type '/style' in the part where you link it. This just takes all the text in that link and uses it for CSS. It gets lengthy when you have a lot of files, and then it is probably better to use the static method i ges, but for not a lot of file you can use this method as it is easy to understand.

Anyway I will edit this post to link the bug report so you can updoot it so it becomes a priority

Thank you por rading tis awesome essay, ba;sl

Voters
Whippingdot
Comments
hotnewtop
Coder100

This is basically just help I can't use python on the web

If a solution exists, use it, the lack of a builtin solution is not a bug, rather it is an inconvenience.

Whippingdot

But isn't it a bug? Or is that just a missing feature - I feel like Nodejs did not specify anywhere that relative links would not work... @Coder100

Coder100

@Whippingdot no?
Express just automatically makes it root for some reason so you have to add dirname or the better path.join.

But this works just fine:
require('./folder/whatever');

And so does this:
fs.readFileSync('./folder/bruh')

Whippingdot

wait wait wait can you show me an example of a website with the first option (the require one)? @Coder100