Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Firebase函数可以';我找不到帕格_Node.js_Firebase_Pug_Google Cloud Functions - Fatal编程技术网

Node.js Firebase函数可以';我找不到帕格

Node.js Firebase函数可以';我找不到帕格,node.js,firebase,pug,google-cloud-functions,Node.js,Firebase,Pug,Google Cloud Functions,我有一个简单的firebase函数,可以呈现一个哈巴狗模板 const functions = require('firebase-functions'); const admin = require('firebase-admin'); const creds = { projectId: "retnikt-blog", privateKey: "-----BEGIN PRIVATE KEY-----\n REDACTED \n-----END PRIVATE KEY-----

我有一个简单的firebase函数,可以呈现一个哈巴狗模板

const functions = require('firebase-functions');
const admin = require('firebase-admin');
const creds = {
    projectId: "retnikt-blog",
    privateKey: "-----BEGIN PRIVATE KEY-----\n REDACTED \n-----END PRIVATE KEY-----\n",
    clientEmail: "REDACTED@REDACTED.iam.gserviceaccount.com"
};

admin.initializeApp({credential: admin.credential.cert(creds)});
const app = require("express")();
const pug = require("pug");
app.engine('pug', pug.__express);
app.set('view engine', 'pug');
app.set('views', '../views');

exports.myFunction = functions.https.onRequest((req, res) => {
    res.render('blog.pug', {
        title: 'title',
        body: 'body',
        author: 'author',
        date: 'date',
        categories: 'categories',
        tags: 'tags'
    });
});
当我运行此函数时,它告诉我
错误:找不到模块'pug'
。我已在项目的根目录中安装了带有NPM的pug,并在我的
package.json
依赖项中指定了pug:

"dependencies": {
    ...
    "pug": "2.0.3"
}
我在全球范围内安装了Pug,现在它在本地工作,但当我部署它时,它只会给出“错误:无法处理请求”,状态为500

我的两个问题是: A) 为什么安装的哈巴狗未被识别, 和 B) “无法处理请求”是否也是因为帕格未被识别

编辑:检查日志后,似乎这是正确的

nodejsv8.10.0
firebase tools 3.18.5

pug必须依赖于functions文件夹中的package.json,而不是根文件夹中的package.json