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

279
Views
When I tried create a EJS template the terminal sends me a error

Hi I'm new into EJS templates and I am trying to create a template for a simple web app, but when I run the app.js file into the HyperTerminal it gives me his error: "TypeError: Router.use() requires a middleware function but got a string at Function.use " Why this happens?????

My javascript code is:

const express=require("express");
const bodyParser=require("body-parser");
const app = express();

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

app.get("/", function (req, res){
  var today = new Date();
  var currentDay = today.getDay();
  var day = "";


switch (currentDay) {
  case 0:
  day="Sunday";
    break;
    case 1:
    day="Monday";
      break;
      case 2:
      day="Tuesday";
        break;
        case 3:
        day="Wednesday";
          break;
          case 4:
          day="Thursday";
            break;
            case 5:
            day="Friday";
              break;
              case 6:
              day="Saturday";
                break;
  default:
console.log("Error");
}

    res.render("list", {kindOfDay: day});

});

app.listen(3000, function(){
  console.log("Server is good and runnning")
});

and my ejs file is:

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>To do List</title>
  </head>
  <body>
<h1>It's a <%= kindOfDay %>!</h1>
  </body>
</html>
about 4 years ago · Juan Pablo Isaza
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!