【发布时间】:2020-01-19 16:07:21
【问题描述】:
尝试使用云功能模拟器时,我收到一条消息:
function ignored because the firestore emulator does not exist or is not running
我试过在这里提到:(Firestore/Firebase Emulator Not Running)。
我的函数/package.json 看起来像这样:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"dependencies": {
"firebase-admin": "^8.0.0",
"firebase-functions": "^3.1.0"
},
"devDependencies": {
"eslint": "^5.12.0",
"eslint-plugin-promise": "^4.0.1",
"firebase-functions-test": "^0.1.6"
},
"private": true
}
我用来启动模拟器的命令:
firebase emulators:start --only functions
这是我得到的输出:
i Starting emulators: ["functions"]
! Your requested "node" version "8" doesn't match your global version "10"
+ functions: Emulator started at http://localhost:5001
i functions: Watching "C:\Users\MyName\Documents\MyProject\functions" for Cloud Functions...
i functions[updateFunction]: function ignored because the firestore emulator does not exist or is not running.
+ All emulators started, it is now safe to connect.
我正在函数中执行 console.log,但在端口 (5001) 上看不到它。
任何帮助将不胜感激。
【问题讨论】:
-
我不明白问题出在哪里。请编辑问题以显示函数的代码、您是如何调用它的,并解释什么没有按您期望的方式工作。
-
函数本身不相关。我们只是说它正在做一个控制台日志。该函数运行,我在部署时看到控制台日志。当我从使用 firestore 数据库的应用程序写入数据库时会触发它。我正在尝试在模拟器中运行该功能。我假设当函数被触发时日志应该出现在模拟器端口(5001)上,但事实并非如此。它确实被触发了,因为我在 firebase 控制台中看到了日志(只是不在模拟器端口上)。我认为这与“由于firestore模拟器而被忽略的功能......”打印有关。这就是问题所在。
-
接下来,我意识到了一件事。由于我只是启动功能模拟器而不是 firestore 模拟器,因此有问题的打印指的是 firestore 模拟器。所以我启动了所有的模拟器,现在我看不到打印了。那么,现在的问题是,Firestore 的更新是否也需要“模拟”更新而不是真正的更新才能触发“模拟”功能?
标签: firebase google-cloud-firestore google-cloud-functions