Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Express Basics Deeper into Routing with Express POST Requests

Getting 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) => {

app.get('/cards', (req, res) => {
    res.render('card', { prompt: "Who is buried in Grant's tomb?"}); 

app.get('/hello', (req, res) => {
app.listen(3000, () => {
    console.log('The application is running on localhost:3000');


extends layout

block content
    h2 HOWDY

Can someone help? Thanks.

1 Answer

Robert Manolis
Robert Manolis
Treehouse Guest Teacher

Hey 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. :thumbsup:

Okay, my snapshot is https://w.trhou.se/leavdvflhq

I figured it out, I put hello.pug in views/includes instead of views.

Robert Manolis
Robert Manolis
Treehouse Guest Teacher

Well 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. :thumbsup:

Thank you!