I am learning by watching tutorials. I don't know what type of error is and how to solve this error.
terminal give me this error
app.engine('handlebars', exphbs());
^
const express = require('express');
const path = require('path')
const port = 3000;
const app = express();
var exphbs = require('express-handlebars');
app.engine('handlebars', exphbs());
app.set('view engine', 'handlebars');
app.use(express.static(path.join(__dirname, "static")));
app.use('/', require(path.join(__dirname, 'routes/blog.js')))
TypeError: exphbs is not a function
app.listen(port, ()=>{
console.log(`blog app running at http://localhost:${port} `);
})
Look at the documentation for the module you are using.
import { engine } from 'express-handlebars'; ... app.engine('handlebars', engine());
It uses ES6 syntax but shows that the engine is available from the engine property of the module and not the top level export.
In your syntax, that would be:
app.engine('handlebars', exphbs.engine());