Firestore/Firebase模拟器未运行 [英] Firestore/Firebase Emulator Not Running
问题描述
我正在尝试使用此处列出的指南在本地测试我的功能 https://firebase.google.com/docs/functions/local-emulator
I'm trying to test my functions locally using the guide listed here https://firebase.google.com/docs/functions/local-emulator
我已使用
npm install -g firebase-tools
在我的package.json
中,我确认正在运行
In my package.json
I confirmed to be running
"firebase-admin": "^7.3.0",
"firebase-functions": "^2.3.1",
当我尝试使用
firebase emulators:start
它给了我下面的输出. 我在做什么错了?
It gives me the below output. What am I doing wrong?
Starting emulators: ["functions"]
⚠ Your requested "node" version "8" doesn't match your global version "11"
✔ functions: Emulator started at http://localhost:5001
i functions: Watching "[FUNCTIONS FOLDER PATH]" for Cloud Functions...
⚠ Default "firebase-admin" instance created!
⚠ Ignoring trigger "[FUNCTION NAME]" because the service "firebaseauth.googleapis.com" is not yet supported.
⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running.
etc.
etc.
etc.
i functions: HTTP trigger initialized at http://localhost:5001/[APP NAME]/us-central1/[FUNCTION NAME]
[2019-05-15T21:43:52.436Z] @firebase/database: FIREBASE WARNING:
{"code":"app/invalid-credential","message":"Credential implementation provided to
initializeApp() via the \"credential\" property failed to fetch a valid Google
OAuth2 access token with the following error: \"Error fetching access token: Error
while making request: getaddrinfo ENOTFOUND metadata.google.internal
metadata.google.internal:80. Error code: ENOTFOUND\"."}
推荐答案
我遇到了同样的问题,我有些问题
I had the same issue there were a few things wrong for me
- 确保通过运行模拟器来安装模拟器 firebase设置:模拟器:firestore
- ensure the emulator is installed by running firebase setup:emulators:firestore
第二个问题是我的初始Firebase配置已将配置文件安装到我的主文件夹中,而不是项目文件夹中,如
My second issue was that my initial firebase configuration had installed the config files into my home folder rather then the project folder as described [here] this meant so my project was missing firestore.rules and firestore.indexes.json and some of the configuration settings.
运行firebase初始化以生成这些文件
run firebase init to generate these files
一旦修复了这两个问题,它便对我有用.我希望这会有所帮助.
Once I fixed these two things it worked for me. I hope this helps.
作为参考,我的firebase.json看起来像这样
As a reference my firebase.json looks like this
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"hosting": {
"public": "dist",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"emulators": {
"firestore": {
"port": "5002"
}
}
}
这篇关于Firestore/Firebase模拟器未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!