【问题标题】:Using firebase tools as a node module in firebase function使用 firebase 工具作为 firebase 功能中的节点模块
【发布时间】:2021-10-01 17:28:59
【问题描述】:

我正在尝试从 firebase 函数中的 firebase 工具节点模块调用导出方法。

    await firebase_tools.auth.export(tempLocalFile);

但我收到以下错误

FirebaseError: No currently active project.
To run this command, you need to specify a project. You have two options:
- Run this command with [1m--project <alias_or_project_id>[22m.
- Set an active project by running [1mfirebase use --add[22m, then rerun this command.
To list all the Firebase projects to which you have access, run [1mfirebase projects:list[22m.
To learn about active projects for the CLI, visit https://firebase.google.com/docs/cli#project_aliases

有没有办法在nodejs云功能中设置活动项目?

编辑

我正在像这样初始化对象

const firebase_tools = require('firebase-tools');

【问题讨论】:

  • 你是想在一个云函数中使用多个 Firebase 项目还是什么?
  • 不只是部署到的那个

标签: node.js firebase google-cloud-functions firebase-tools


【解决方案1】:

我并没有完全回复您的问题,但请注意auth.export 命令在云函数中不起作用。

documentation 中所述(见底部注释):

在 Cloud Functions 等有限环境中使用时,并非全部 firebase-tools 命令将以编程方式工作因为它们需要 访问本地文件系统

auth.export 命令就是这种情况。另一种方法是使用 Admin SDK 的 listUsers() 方法,如 here 所述。

【讨论】:

    猜你喜欢
    • 2022-01-03
    • 2020-01-03
    • 1970-01-01
    • 2018-06-25
    • 1970-01-01
    • 2018-04-04
    • 2021-05-24
    • 2020-09-23
    • 1970-01-01
    相关资源
    最近更新 更多