Advanced Node and Express - Set up a Template Engine

Tell us what’s happening:

When I render the ./views/pug it gets and error: Here is my code:

'use strict';
require('dotenv').config();
const express = require('express');
const myDB = require('./connection');
const fccTesting = require('./freeCodeCamp/fcctesting.js');

const app = express();

fccTesting(app); //For FCC testing purposes
app.set('view engine', 'pug');
app.use('/public', express.static(process.cwd() + '/public'));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

app.route('/').get(

###Your project link(s)

solution: https://3000-freecodecam-boilerplate-5k6y4fe243u.ws-eu114.gitpod.io

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

Challenge Information:

Advanced Node and Express - Set up a Template Engine

Where is the rest of your code?


After that, add another set method that sets the views property of your app to point to the ./views/pug directory. This tells Express to render all views relative to that directory.

Finally, use res.render() in the route for your home page, passing index as the first argument. This will render the pug template.