i have made the handlebars template config on my index.js file, but when i try to run my code with nodemon he returns me this error. anyone can help?
enter image description here
enter image description here
Your initialization of engine on line 8 is wrong.
Please change it to app.engine('handlebars', engine());. Check the snippet below.
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");
app.get('/', (req, res) => {
res.render('home');
});
app.listen(3000);
Insert .engine after handlebars, look:
app.engine('handlebars', handlebars.engine({ defaultLayout: 'main' }));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With