TypeError: hbs is not a function at Object. (D:\Brototype\Web Development Challenge-2\shopping-cart\app.js:17:19) at Module._compile (node:internal/modules/cjs/loader:1256:14) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) at Module.load (node:internal/modules/cjs/loader:1119:32) at Module._load (node:internal/modules/cjs/loader:960:12) at Module.require (node:internal/modules/cjs/loader:1143:19) at require (node:internal/modules/cjs/helpers:119:18) at Object. (D:\Brototype\Web Development Challenge-2\shopping-cart\bin\www:7:11) at Module._compile (node:internal/modules/cjs/loader:1256:14) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
Node.js v18.18.0 [nodemon] app crashed - waiting for file changes before starting... -------------------------------------This is my app.js code Why showing this error while i already installed express-handlebars and connect engin in app.js
I try to run my code in terminal but It shoing error. I need to run my server and check output on browser
Your usage of handlebars is not correct. You need to call the hbs.engine
function instead like so:
app.engine("hbs", hbs.engine({
extname: "hbs",
defaultLayout: "layout",
//...
}));