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)