Basic Node and Express - Serve Static Assets

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

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.

I have this at the end of the file but it still doesn’t work

I have style.css file enabled in Chrome but not in Simple Browser in VisualStudio



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.

I tried running it through GitPod in the browser and it finally worked for me, thanks for taking the time to find the problem