Basic Node and Express - Serve Static Assets

Tell us what’s happening:
I am trying to complete the challenge and it does not work. I literally copy and paste the solution from the forum and it is not working. I don´t know why.

This is my code

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

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

app.get("/", (req, res) => {
  res.sendFile(`${__dirname}/views/index.html`);
});

Your project link(s)

solution: boilerplate-express-1 - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36

Challenge: Basic Node and Express - Serve Static Assets

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.