ox1s
November 9, 2024, 3:27pm
1
Tell us what’s happening:
I don’t know why this doesn’t work…
let express = require(‘express’);
let app = express();
app.use(‘/public’, express.static(__dirname + ‘/public’));
const absolutePath = __dirname + ‘/views/index.html’;
app.get(‘/’, (req, res) => {
res.sendFile(absolutePath);
});
Challenge Information:
Basic Node and Express - Serve Static Assets
ox1s:
let express = require(‘express’);
let app = express();
app.use(‘/public’, express.static(__dirname + ‘/public’));
const absolutePath = __dirname + ‘/views/index.html’;
app.get(‘/’, (req, res) => {
res.sendFile(absolutePath);
Try using const instead of let.
You are missing module.exports = app;
at the bottom of the file. Other than that, your code should pass.
ox1s
November 13, 2024, 6:34pm
4
I have this at the end of the file but it still doesn’t work
ox1s
November 13, 2024, 7:08pm
5
I have style.css file enabled in Chrome but not in Simple Browser in VisualStudio
lasjorg
November 13, 2024, 7:47pm
6
How are you running this? What is it with the SSH to a GitPod?
Clone the boilerplate down locally and run it from there. Make sure you start the server using the package.json start script npm run start
from the terminal.
There isn’t anything wrong with the code as far as I can tell.
ox1s
November 14, 2024, 8:21am
7
I tried running it through GitPod in the browser and it finally worked for me, thanks for taking the time to find the problem