【发布时间】:2020-10-21 02:52:37
【问题描述】:
我正在尝试通过以下方式部署我的 Firebase Cloud Function:
firebase deploy --only functions:helloWorld
我的问题是该命令有时会成功,但大多数时候它会因上述错误而失败。可能是什么原因,如何解决?
我遇到了similar question 并尝试了许多推荐的解决方案(清除 npm 缓存并重新安装依赖项)。这两种解决方案对我来说都不可靠。
这是完整的控制台输出:
=== Deploying to '<my-firebase-project>'...
i deploying functions
✔ functions: Finished running predeploy script.
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔ functions: required API cloudbuild.googleapis.com is enabled
✔ functions: required API cloudfunctions.googleapis.com is enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (84.76 KB) for uploading
✔ functions: functions folder uploaded successfully
i functions: current functions in project: myFunction1(us-central1), myFunction2(us-central1), myFunction3(us-central1)...
i functions: uploading functions in project: helloWorld(us-central1)
i functions: updating Node.js 10 function helloWorld(us-central1)...
⚠ functions[helloWorld(us-central1)]: Deployment error.
Build failed: npm ERR! Maximum call stack size exceeded
npm ERR! A complete log of this run can be found in:
npm ERR! /builder/home/.npm/_logs/2020-10-15T17_38_33_530Z-debug.log; Error ID: 49341d49
Functions deploy had errors with the following functions:
helloWorld
To try redeploying those functions, run:
firebase deploy --only "functions:helloWorld"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
部分问题是我不知道在哪里可以找到 firebase deploy 命令输出中提到的完整日志在 /builder/home/.npm/_logs/2020-10-15T17_38_33_530Z-debug.log
这是我的 firebase/functions 配置文件:
./functions/index.js:
const functions = require('firebase-functions');
// Create and Deploy Your First Cloud Functions
// https://firebase.google.com/docs/functions/write-firebase-functions
exports.helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
});
./firebase.json:
{
"functions": {
"predeploy": [
],
"source": "functions",
"runtime": "nodejs10"
},
"emulators": {
"functions": {
"port": 5001
},...
}
...
}
./functions/package.json:
{
"name": "functions",
"description": "Backend - Firebase Cloud Functions",
"version": "1.0.0",
"scripts": {
"lint": "eslint .",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "14.3.0"
},
"dependencies": {
"config": "^3.3.1",
"core-util-is": "^1.0.2",
"crypto-js": "^4.0.0",
"firebase-admin": "^9.1.1",
"firebase-functions": "^3.11.0",
"myapp_config": "file:./config"
},
"devDependencies": {
"eslint": "^5.12.0",
"eslint-plugin-promise": "^4.0.1",
"firebase-functions-test": "^0.2.0"
},
"private": true
}
开发栈:
- macOS 10.15+
- 节点版本 = v14.3.0
【问题讨论】:
-
你是说它给你的日志文件是空的或丢失的还是什么?只需
cat文件即可查看其中的内容。问题可能出在您的代码上,因此您应该编辑问题以显示重现该问题的 complete minimal code,以便任何人都可以使用您提供的说明重现此问题。 -
@DougStevenson 我不知道日志文件在哪里。当我这样做时,
ls /builder/home我得到:ls: /builder/home: No such file or directory。它应该在 macOS 机器上的什么位置? -
@DougStevenson 我编辑了这个问题以提供一个最小的例子 - 上面的
index.js文件是否足够或需要其他任何东西? -
我在这里没有看到问题,但是该日志文件的内容应该有您需要的内容。如果 CLI 没有为您提供关于部署期间出现问题的完整或可操作的错误,您应该直接联系 Firebase 支持。 support.google.com/firebase/contact/support
标签: firebase npm deployment google-cloud-functions