Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
What can I do to render this EJS template file?

My app does not work. I've reduced the code to bare basics trying to find the mistake. Any ideas?

This is the project file structure. There are no other files or folders besides the listed below.

  • Project folder (folder)
    • app.js (file)
    • views (folder)
      • home.ejs (file)

This is the app.js content:

// jshint esversion:6
const express = require(`express`);
const ejs = require(`ejs`);
const app = express();

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

app.get("/", function(req, res) {
  res.render(`home`);
});

app.listen(3000, function() {
  console.log(`The server is now on.`);
});

This is the home.ejs content:

<!DOCTYPE html>
<html lang=`en` dir=`ltr`>

<head>
  <meta charset=`utf-8` />
  <title>Secrets</title>
</head>

<body>
  <h1>Secrets</h1>
</body>

</html>

I ran npm init to create this app and npm i express ejs to install the dependencies.

The error I get is the following:

Error: Failed to lookup view "home" in views directory...full path

Any ideas why this is not running properly?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are missing to state where the root folder for ejs files will be.

var path = require('path');
app.set('views', path.join(__dirname, './views'));

Also, for me I set view engine like this:

app.engine('.ejs', ejs.__express);

For me it works, see a glitch for a demo.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!