从Firebase Functions Shell引用本地配置变量的Firebase函数调用时出错 [英] Error invoking firebase function referencing local configuration variables from Firebase Functions Shell

查看:65
本文介绍了从Firebase Functions Shell引用本地配置变量的Firebase函数调用时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是解决此问题的延续以及与实施建议的解决方案有关的单独问题.

This is a continuation of troubleshooting this problem and a separate issue related to implementing a suggested solution.

我正在尝试从本地服务环境中使用Firebase功能配置此处概述,但出现意外错误.

I am attempting to consume Firebase function configuration from a locally-served environment as outlined here but I get an unexpected error.

  1. 我在函数目录中创建一个包含以下内容的".runtimeconfig.json"文件:

{ 身份验证":{ "clientid":MY_CLIENT_ID, "signoutreturnto":SOME_URL, "responsetype":SOME_URL, "redirecturi":SOME_OTHER_URL, 范围":SOME_OTHER_STRING, 域":SOME_DOMAIN } }

{ "auth": { "clientid": MY_CLIENT_ID, "signoutreturnto": SOME_URL, "responsetype": SOME_URL, "redirecturi": SOME_OTHER_URL, "scope": SOME_OTHER_STRING, "domain": SOME_DOMAIN } }

  1. 我从firebase CLI(在functions目录中)执行以下命令:

  1. I execute the following commands from the firebase CLI (within the functions directory):

  • firebase函数:config:get> .runtimeconfig.json
  • firebase实验性:functions:shell

我通过cli执行配置功能:

I execute my config function via the cli:

config()

我在控制台中收到以下错误输出:

I get the following error output in the console:

config()

TypeError: config is not a function
    at repl:1:1
    at ContextifyScript.Script.runInContext (vm.js:32:29)
    at REPLServer.defaultEval (repl.js:341:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.onLine (repl.js:536:10)
    at emitOne (events.js:96:13)
    at REPLServer.emit (events.js:191:7)
    at REPLServer.Interface._onLine (readline.js:241:10)
    at REPLServer.Interface._line (readline.js:590:8)

我的其他功能,bigben& firebaseConfig按预期从CLI执行

my other functions, bigben & firebaseConfig execute as expected from the CLI

推荐答案

如果要在CLI仿真器提示符下查看功能配置,则应从功能目录运行仿真器命令:

If you want to see your functions config at the the CLI emulator prompt, you should run the emulator command from your functions directory:

$ cd functions
$ firebase experimental:functions:shell

然后,在firebase提示符下,您可以按以下方式访问您的配置:

Then, at the firebase prompt, you can access your config like this:

firebase> const functions = require('firebase-functions')
firebase> functions.config()

那应该打印您的配置.通常,您不需要执行此类操作-您只需使用functions.config()从仿真函数内部读取配置即可.

That should print your config. Normally you don't need to do something like this - you would instead just read the config from inside the emulated function using functions.config().

这篇关于从Firebase Functions Shell引用本地配置变量的Firebase函数调用时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆