【问题标题】:Unhandled rejection Error: Cannot find module 'handlebars' in firebase hosting using express未处理的拒绝错误:在使用 express 的 firebase 托管中找不到模块“handlebars”
【发布时间】:2018-07-28 03:18:48
【问题描述】:

const functions = require('firebase-functions');
const admin		= require('firebase-admin');
const express	= require('express');
const engines	= require('consolidate');

const app		= express();

const firebaseApp	= admin.initializeApp(
	functions.config().admin
);

app.engine('hbs', engines.handlebars); =>> this handlebars can't be loaded
app.set('views', './views');
app.set('view engine', 'hbs');

app.get('/time', (req, res)=>{
	res.set('Cache-Control', 'public, max-age=300, s-maxage=600');
	res.render('index')
});
exports.app = functions.https.onRequest(app);

与这个项目有关 index.js

我在 firebase 托管、firebase cli 中使用 expressjs,我需要视图引擎来获取视图模板 hbs 但我无法获取文件

【问题讨论】:

    标签: javascript node.js firebase express


    【解决方案1】:

    来自consolidate's readme

    注意:您仍然必须安装您希望使用的引擎,将它们添加到 您的 package.json 依赖项。

    Install handlebars 通过运行,npm install --save handlebars

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-08
      • 2016-01-29
      • 2019-10-13
      相关资源
      最近更新 更多