繁体   English   中英

类型错误:车把不是 function - 解决方案?

[英]TypeError: handlebars is not a function - Solution?

运行 nodemon 时出现此错误。

给我带来了这条信息 - app.engine("handlebars",handlebars({defaultLayout:'main'})); ^

类型错误:车把不是 Object 的 function。 (C:\Users\yrvsc\Documents\CrudoNodeJs\app.js:8:25)

在此处输入图像描述

 const express=require('express'); const bodyParser=require('body-parser'); const mysql=require('mysql'); const handlebars = require('express-handlebars'); const app=express(); app.engine("handlebars",handlebars({defaultLayout:'main'})); app.set('view engine','handlebars'); app.get("/",function(req,res){ res.render('index'); }); app.listen(3000,function(req,res){ console.log('Servidor está rodando;'); });

const hbs = handlebars.create({ defaultLayout:'main' });
app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM