如何在firebase项目中设置firebase_config和gcloud_project [英] how to set firebase_config and gcloud_project in firebase project

查看:70
本文介绍了如何在firebase项目中设置firebase_config和gcloud_project的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行index.js文件,它向我显示以下错误

I tried to run the index.js file and it shows me the below error

C:\blog\functions>node index.js
{"severity": "WARNING", "message": "Warning, FIREBASE_CONFIG and GCLOUD_PROJECT environment variables are missing. Initializing firebase-admin will fail"}```

i know that 

firebase函数:config:set someservice.key =" API KEY"someservice.id =客户端ID"

firebase functions:config:set someservice.key="THE API KEY" someservice.id="THE CLIENT ID"

this command will set environmental variables but what values should I set in environmental variables

I don't understand these lines from firebase documentation: (https://firebase.google.com/docs/functions/config-env)
process.env.GCLOUD_PROJECT: Provides the Firebase project ID
process.env.FIREBASE_CONFIG: Provides the following Firebase project config info:

should i set firebaseConfig details from project settings into environmental variables

推荐答案

FIREBASE_CONFIG GCLOUD_PROJECT 是Firebase Functions服务器上的环境变量.未设置它们的原因是因为您试图在标准节点环境( node index.js )中运行函数代码,而不是在Firebase生产服务器或本地环境中运行它们通过firebase-tools软件包的 serve shell emulate 进行本地模拟,并为您提供正确的配置.

FIREBASE_CONFIG and GCLOUD_PROJECT are environment variables on Firebase Functions servers. The reason they're not set is because you're trying to run your functions code in a standard node environment (node index.js) instead of running them on the Firebase production servers or in your local environment through the firebase-tools package's serve, shell or emulate which would locally mock the servers and give you the right config.

您不必设置这些值-只需在Firebase模拟器(或Shell)中运行您的函数即可.查看有关如何启动和运行的文档.

You don't have to set these values - just run your functions in the Firebase emulator (or shell). Check out the docs on how to get up and running.

这篇关于如何在firebase项目中设置firebase_config和gcloud_project的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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