【发布时间】:2020-11-13 01:15:13
【问题描述】:
我一直在尝试部署名为 onFollowUser 的 firebase 函数,但是它一直无法启动。我目前有 Blaze 计划,这是错误消息:
⚠ functions[onFollowUser(us-central1)]: Deployment error.
Failed to configure trigger providers/cloud.firestore/eventTypes/document.create@firestore.googleapis.com (__gcf__.us-central1.onFollowUser)
Functions deploy had errors with the following functions:
onFollowUser
To try redeploying those functions, run:
firebase deploy --only functions:onFollowUser
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
这是我完整的index.js:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.onFollowUser =
functions
.firestore
.document('/Followers/{userID}/User Follower/{followerID}')
.onCreate(async (snapshot, context) => {
console.log(snapshot.data());
});
我发现了错误...我的数据库位于欧洲中部,但是,由于某种原因,它正在部署到美国中部...我该如何更改?它说它正在部署到的我的项目的 ID 是正确的。
这是我的 package.json:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"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": "10"
},
"dependencies": {
"firebase-admin": "^8.10.0",
"firebase-functions": "^3.6.1"
},
"devDependencies": {
"eslint": "^5.12.0",
"eslint-plugin-promise": "^4.0.1",
"firebase-functions-test": "^0.2.0"
},
"private": true
}
【问题讨论】:
-
你能分享你的
package.json文件吗? -
“我的数据库位于欧洲中部,但是,由于某种原因,它正在部署到美国中部...” 在一个位置拥有一个 Firestore 数据库并拥有一个应该没有问题另一个位置的云功能。请参阅以下链接更改区域:firebase.google.com/docs/functions/…
-
感谢@RenaudTarnec 和 Mike,它现在正在部署
-
这可能是一个有趣的答案......我部署正确,但随后,我开始遇到同样的问题。在花了 4 个小时试图修复它之后......我发现我的结算帐户已被暂停,因为我最后一次支付 0.01 美元失败了。我刚刚添加了一种新的付款方式,我的部署又开始工作了。
标签: firebase flutter google-cloud-firestore google-cloud-functions