Error while using ejs

This is my code:

let express = require('express');
let bodyParser = require('body-parser');
let ejs = require('ejs');

let app = express();

app.get("/",function(req,res){
    let today = new Date();
    let currentDay = today.getDay();
    if(currentDay == 0 || currentDay == 6){
        res.render('list',{day: 'Weekend'});
    }
    else{
        res.render('list',{day: 'Get back to work'});
    }
});

app.listen(3000, function(){console.log('Server is running.');});

and this the error im getting:

Please help me rectify my mistake.

Did you try researching that error?

A quick google search suggests you may need to declare ejs as your view engine:

app.set('view engine', 'ejs');

Might be a place to start.

1 Like