node.js - Firebase 函数错误 : The default Firebase app

以前,该功能有效。但是我添加了一些代码,现在这个错误来了。如何解决这个问题?

Error: Error occurred while parsing your function triggers.

Error: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services.
    at FirebaseAppError.FirebaseError [as constructor] (/Users/demo/functions/node_modules/firebase-admin/lib/utils/error.js:42:28)

代码

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
import { getLocations, getLocationsByType } from '../service/locationQuery/locationQuery';

//I tried both way, but same error came
// admin.initializeApp(functions.config().firebase);
admin.initializeApp();
exports.findUsers = functions.https.onCall(async (data: any, context: any) => {

最佳答案

我更改了初始化位置.. 现在可以正常工作了。我不知道为什么会这样。

import * as admin from 'firebase-admin';
admin.initializeApp();//add to here
import { getLocations, getLocationsByType } from '../service/locationQuery/locationQuery';

// admin.initializeApp(functions.config().firebase);

exports.findUsers = functions.https.onCall(async (data: any, context: any) => {

关于node.js - Firebase 函数错误 : The default Firebase app does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60262246/

相关文章:

javascript - 运算符 '<' 不能应用于类型 'Date' 和 'number' .ts

powershell - Terraform azurerm_virtual_machine_ext

javascript - 如何模拟 axios.create([config]) 函数以返回其实例方

oracle - 在 Apex 中提交表单之前添加确认

python - 如何在python中创建文件夹?

sql - 我如何允许sql中的重复值?

list - 得到 "Fatal error: Index out of range": show

typescript - typescript 中的 bool 列表是否有 "all"或 "any"

three.js - 如何使用 threejs 在 iPhone 上启用视网膜分辨率 render.

ios - 从 XCode 的调试导航器中清除崩溃日志