google-cloud-firestore - 当函数目录位于不同的项目/位置时运行 firebase 模拟器

标签 google-cloud-firestore google-cloud-functions firebase-tools

我在 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.

更新: 我的文件夹结构。

  1. R:/customer/customer-cloud-project/functions
  2. R:/customer/customer-web-app/

我可以很好地运行位置 2 中的所有模拟器,但函数模拟器除外,因为没有函数目录。 因此,我在函数文件夹的位置 1 中运行以下命令: firebase 模拟器:start --only 函数

这工作正常,因为它运行模拟器的 2 个实例。但是,触发器/后台功能不会运行,因为它找不到在不同端口上运行的 firestore 模拟器。

最佳答案

解决这个问题的方法是使用符号链接(symbolic link)。 这基本上是函数项目中另一个目录的快捷方式。

如果其他人想执行此操作,Windows 上的命令是: mklink/D "R:\firestore-project\functions""R:\cloud-functions-proj\functions"

您需要以管理员身份运行命令提示符。

请在此处查看我的问题以了解更多详细信息: https://github.com/firebase/firebase-tools/issues/3092#issuecomment-771159457

注意: 创建符号链接(symbolic link)时可以指定绝对或相对路径。 相对是最好的选择,否则它不太可能在其他人的环境中工作。在要创建链接的目录中运行此命令:

mklink /D "models" "..\..\..\myapp\src\app\models"

关于google-cloud-firestore - 当函数目录位于不同的项目/位置时运行 firebase 模拟器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65945743/

相关文章:

node.js - 当我尝试保存到 Firestore 时,为什么我的 Firebase HTTPS 功能会变得静默?

python - 如何从 Google 云函数返回 JSON

firebase - 如何在云功能中的两个 firebase 项目之间切换?

firebase - 使用 Firebase 托管部署 Vue.js 应用程序

firebase - Flutter firebase 从真实设备连接到模拟器

firebase - Firestore 中的 getDocuments() 和 snapshots() 有什么区别?

java - 对象的 Firestore 更新列表

firebase - 使用 Firestore 的 Flutter 产品列表和详细信息

ruby-on-rails - 如何使用 Active Storage 保留存储空间和加载时间?

firebase批量更新和onWrite触发同步