Closed moshema10 closed 3 years ago
I am using handlebars for the first time in my project. I am facing this type error. Can anyone help me fix this?
CODE:
const express = require('express'); const app = express(); const bodyParser = require('body-parser'); const exphbs = require('express-handlebars');
app.use(express.static(__dirname + "/public")); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended: true}));
app.set("view engine","hbs"); app.engine('hbs',exphbs({ extname: 'hbs', defaultLayout: 'index' }));
ERROR:
app.engine('hbs',exphbs({ ^
TypeError: exphbs is not a function
The latest version removed the default export.
const { engine } = require('express-handlebars'); ... app.engine('hbs',engine({...
Thanks @UziTech It worked!!!
I am using handlebars for the first time in my project. I am facing this type error. Can anyone help me fix this?
CODE:
const express = require('express'); const app = express(); const bodyParser = require('body-parser'); const exphbs = require('express-handlebars');
app.use(express.static(__dirname + "/public")); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended: true}));
app.set("view engine","hbs"); app.engine('hbs',exphbs({ extname: 'hbs', defaultLayout: 'index' }));
ERROR:
app.engine('hbs',exphbs({ ^
TypeError: exphbs is not a function