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 Using Templates with Express Express’s Response.render Method

Daniel Hernandez
Daniel Hernandez
13,437 Points

I keep getting "Error: Failed to lookup view "card" in views directory"

I continually keep getting the same error and don't know what I am doing wrong. It says 'error:failed to lookup view "card" in views directory'.Here is my javascript code, any help would be very much appreciated, thank you.

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.locals.prompt = "Who is buried in Grant's tomb?";
    res.render('card');
});

app.listen(3000, ()=> {
  console.log('The application is running on port 3000')
});

1 Answer

Daniel Hernandez
Daniel Hernandez
13,437 Points

Never-mind I solved it. I forgot to duplicate the index.pug file and make a card.pug file. Such a silly mistake to make! Never-mind everybody, sorry.