DEV Community

Thiago
Thiago

Posted on

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");

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More