一个月后,我回到开发环境并运行firebase serve --only functions
。它给我的消息很少,我应该更新我的软件包。我只是按照指示进行操作,因此在开发计算机上本地运行的云功能被破坏了:(我从头开始重新启动所有功能,并将所有依赖项更新为最新。不幸的是,我遇到了一些认证问题,我没有运气: (
我收到此错误:
Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
packages.json
:
{
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "^8.2.0",
"firebase-functions": "^3.0.2",
"firebase-tools": "^7.0.2",
"google-gax": "^1.1.3"
},
"devDependencies": {
"tslint": "^5.12.0",
"typescript": "^3.2.2"
},
"private": true
}
我已将评论添加到related Github issue here
答案 0 :(得分:1)
如果有人遇到类似问题。
对我而言,将使用config()
的初始化firebase-admin切换为手动传递service-account-cred解决了身份验证问题。
获取最新更新后无法正常工作
admin.initializeApp(functions.config().firebase);
工作解决方案
var admin = require("firebase-admin");
var serviceAccount = require("firebase-adminsdk.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://<project>.firebaseio.com"
});