Res.render not working, Failed to lookup view "../index" in views directory "/app/views"

Link to project: https://glitch.com/edit/#!/gli-forktery?path=server.js%3A11%3A3

Starting on line 9, I have a app.get function that is supposed to show my index.ejs file to the viewer. The index.ejs file is in the views folder, like it is supposed to. However, when I show my project next to the code, I see this:


What am I doing wrong? It seems like Glitch thinks my code is trying to server “…/index” instead of “index”.

I was able to fix this error. However, now my index.ejs file does not consume the styles I placed in it with a link tag <link rel="stylesheet" type="text/css" href="styles.css">. Do I have to explicitly serve these files with express?

You should set a public directory.
Can I get an invite? (Invite isn’t working, might be glitch downtime?)

Works fine for me :slight_smile: Edit: to be able to edit click on your profile and click ‘request to edit’

Hey i know you! XD

You should move your style.css into your public directory and then add something like this line

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

Then your style.css will be avaliable at https://gli-forktery.glitch.me/style.css and you can link it using that path or relative paths for that

2 Likes