Node.js expresss static not working or something

ok so i dont think the app.use(express.static()) is working anymore as the page it is supposed to work on such as name.username.repl.co isnt working and then i have to go to another page such as name--username.repl.co and in that website there still is an error saying “Uncaught SyntaxError: Invalid or unexpected token (at (index):1:27)” and then when i check the index.html file, there are 2 of them and the one that its using has this in it: document.body.innerHTML = \ ; so I dont know why it is happening and i may be very hard to understand, but i dont have time, so if you can help, thank you

Hey, @coolgamermoth welcome to the forums!

Can you please provide a link to the repl? This way it is easier for staff and members of the community to help you!

Also see this guide on how to share your code:

2 Likes

Alright. i have setup an express static.

const express = require('express');
const app = express();

// This tells Express to serve static files from the given directory
app.use(express.static('public'));

// Now files from 'public folder' are being served

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

this should run without error

1 Like

Uhh so here is my repl(im on a different account rn) https://replit.com/@12bits20/dollarDSATdollarfaR-2?v=1

And i did that same thing, but I cant seem to figure out why it is showing me an error, and now its saying cannot parse given error object soooo

It seems to be working.

That’s another problem, it works fine on ipad, while showing an error, but when I go on pc, it doesnt work and I have to go to the weird link with the — and it will show the error there

So I dont know why its being this weird

@12bits20 When running your repl, the page loads, but an entirely different message appears:


Do you see this on your side too?

1 Like

I did too.

When running the repl from Replit itself, it gave that error, but when opening the website in a new tab, the error never appeared…