设置带有车把的视图引擎
const express = require('express');
const mongoose = require('mongoose');
const path = require('path');
const hbs = require('express-handlebars');
const app = express();配置猫鼬以连接到mongodb
mongoose.connect('mongodb://localhost:27017/1st-cms-db', { useNewUrlParser: true })
.then(response => {
console.log('Database is connected successfuly')
}).catch(err => {
console.log('Database connection failled')
})安装视图引擎以使用
app.engine('handlebars', hbs({ defaultLayouts: true }));
app.set('view engine', 'handlebars');我得到的错误是
app.engine('handlebars', hbs({ defaultLayouts: true }));
^
TypeError: hbs is not a function发布于 2022-06-14 15:21:21
确保安装此软件包:npm install express-handlebars
https://stackoverflow.com/questions/72619462
复制相似问题