Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialbabyoscar
12,930 PointsGetting error for "hello" route
It's throwing "Error: Failed to lookup view "hello" in views directory" (shortened version of the error) whenever I go to localhost:3000/hello Here is my code: app.js:
const express = require('express');
const app = express();
app.set('view engine', 'pug');
app.get('/', (req, res) => {
res.render('index');
});
app.get('/cards', (req, res) => {
res.render('card', { prompt: "Who is buried in Grant's tomb?"});
});
app.get('/hello', (req, res) => {
res.render('hello');
});
app.listen(3000, () => {
console.log('The application is running on localhost:3000');
});
hello.pug:
extends layout
block content
h2 HOWDY
Can someone help? Thanks.
1 Answer
Robert Manolis
Treehouse Guest TeacherHey babyoscar , I can't tell what's wrong based on what I can see here. But if you share a link to a repo with your files or a workplace snapshot link, I should be able to run the app locally and determine where the issue is.
babyoscar
12,930 Pointsbabyoscar
12,930 PointsOkay, my snapshot is https://w.trhou.se/leavdvflhq
babyoscar
12,930 Pointsbabyoscar
12,930 PointsI figured it out, I put
hello.pug
inviews/includes
instead ofviews
.Robert Manolis
Treehouse Guest TeacherRobert Manolis
Treehouse Guest TeacherWell done, babyoscar! Way to stick with it and sort it out. Very developer like! And sorry about not getting back to you on this. I don't believe I ever received a notification of your response. Or if I did, it got accidentally deleted somehow. Either way, apologies for that. And keep up the great work.
babyoscar
12,930 Pointsbabyoscar
12,930 PointsThank you!