handlebars: TypeError: exphbs is not a function

thiagoanjos

Thiago

Posted on March 13, 2024

handlebars: TypeError: exphbs is not a function

I was trying to use handlebars as my template engine on nodejs doing this:

const exphbs = require("express-handlebars");
app.engine("hbs", exphbs());
app.set("view engine", "hbs");
app.set("views", "views");

but this gerate an error:

error

To fix this, I had to change the way I import

const express = require('express');
const { engine } = require('express-handlebars');
const app = express();
app.engine('handlebars', engine());
app.set('view engine', 'handlebars');
app.set("views", "./views");

đź’– đź’Ş đź™… đźš©
thiagoanjos
Thiago

Posted on March 13, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related