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

338
Views
TypeError: expressHandlebars is not a function

When using express-handlebars module,there encounter an error that saying,

app.engine('handlebars', expressHandlebars({
                         ^

TypeError: expressHandlebars is not a function

My code is as follows

const express = require('express')
const expressHandlebars = require('express-handlebars')
const app = express()
// configure Handlebars view engine
app.engine('handlebars', expressHandlebars({
     defaultLayout: 'main',
}))
app.set('view engine', 'handlebars')
..........

I can't find any mistake in here because above code snippet is purely from book that I refer. But it doesn't seem to work.

I will be grateful if someone can to tell that is this because version different of express-handlebars between me and the book I refer or, Is there any mistake in the code.

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

0

You should require the express handlebars engine instead of the whole expressHandlebars package.

Change:

const expressHandlebars = require('express-handlebars')

To:

const expressHandlebars = require('express-handlebars').engine;
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!