Error invoking firebase function referencing local configuration variables from Firebase Functions Shell

送分小仙女□ 提交于 2019-12-14 04:06:40

问题


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

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

  1. I create a ".runtimeconfig.json" file within my functions directory containing this:

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

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

    • firebase functions:config:get > .runtimeconfig.json
    • firebase experimental:functions:shell
  2. I execute my config function via the cli:

    config()

  3. 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)

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


回答1:


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

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

firebase> const functions = require('firebase-functions')
firebase> 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().




回答2:


Are you sure you are on the latest version of firebase-tools? You can update by running 'npm install -g firebase-tools'. You should be on v3.17.4, there was a known bug that was resolved in that version.



来源:https://stackoverflow.com/questions/49139823/error-invoking-firebase-function-referencing-local-configuration-variables-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!