【发布时间】:2021-05-02 20:34:57
【问题描述】:
我在 Windows 10 机器上本地运行所有 Firebase 模拟器。 但是,我正在单独运行我的函数模拟器,因为函数目录位于不同的项目/位置。 看来触发器没有被模拟,我收到下面的警告。除了触发器/背景功能之外的所有东西似乎都可以正常工作。
有什么解决办法吗?
i emulators: Starting emulators: functions
! hub: emulator hub unable to start on port 4400, starting on 4401 instead.
! emulators: It seems that you are running multiple instances of the emulator suite for project myproject-dev. This may result in unexpected behavior.
! functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, firestore, database, hosting, pubsub
! Your requested "node" version "10" doesn't match your global version "12"
! logging: Logging Emulator unable to start on port 4500, starting on 4501 instead.
! ui: Emulator UI unable to start on port 4000, starting on 4003 instead.
i ui: Emulator UI logging to ui-debug.log
i functions: Watching "R:\myproject\myprojectCloud\functions" for Cloud Functions...
! functions: The Cloud Firestore emulator is not running, so calls to Firestore will affect production.
i functions[memberUpdate]: function ignored because the firestore emulator does not exist or is not running.
更新: 我的文件夹结构。
- R:/customer/customer-cloud-project/functions
- R:/customer/customer-web-app/
我可以运行位置 2 中的所有模拟器,除了函数模拟器,因为没有函数目录。 因此,我在函数文件夹的位置 1 中运行以下命令: firebase 模拟器:启动 --only 函数
这很好用,因为它运行了 2 个模拟器实例。但是,触发器/后台功能不会运行,因为它找不到在不同端口上运行的 firestore 模拟器。
【问题讨论】:
-
“函数目录位于不同的项目/位置”是什么意思?您是否有多个项目,一个具有 Firestore,另一个具有功能?您从哪个目录运行每个模拟器?您提供的信息越多,我们就越容易理解问题。现在我无法重现你的设置。
-
我有 2 个项目。一个用于我的云功能,另一个用于我的前端应用程序,我还使用规则、索引等初始化了 firestore。模拟器似乎需要与 firestore 项目在同一项目中的“functions”目录才能一起运行它们。这说明清楚了吗?
-
向问题添加了更多信息
-
是的,据我了解,“functions”目录必须与firestore项目位于同一项目中。
-
@marian.vladoi 我找到了解决方案。在下面添加。
标签: google-cloud-firestore google-cloud-functions firebase-tools