const express = require('express');
const app = express();
//set up handlebars
const handlebars = require('express-handlebars');
app.engine("handlebars",handlebars())
app.set("view engine", "handlebars")
const sqlite3 = require('sqlite3');
const sqlite = require('sqlite');
const port = 8080
const dbPromise = sqlite.open({
filename:"./database/sakila.sqlite",
driver: sqlite3.Database
})
app.get("/",(req,res)=>{
res.render("home",{layout:false});
})
app.listen(port,()=>{
console.log(`server running on ${port}`);
})
I was following a lecture video to learn about handlebars. I typed the same code word by word to set up handlebars and I did npm install express-handlebars --save. The instructor's code is working but mine is not. It only warns me that
"app.engine("handlebars",handlebars()) ^
TypeError: handlebars is not a function
" I couldn't figure out why. Please help. Thank you in advance.
const express = require("express");
const handlebars = require("express-handlebars");
const app = express();
//set up handlebars
app.engine("handlebars", handlebars());
app.set("view engine", "handlebars");
const sqlite3 = require("sqlite3");
const sqlite = require("sqlite");
const port = 8080;
const dbPromise = sqlite.open({
filename: "./database/sakila.sqlite",
driver: sqlite3.Database
});
app.get("/", (req, res) => {
res.render("home", { layout: false });
});
app.listen(port, () => {
console.log(`server running on ${port}`);
});