运行 functions 目录位于不同目录时的 firebase 模拟器 project/location

Running the firebase emulators when the functions directory is in a different project/location

我 运行 在 windows 10 机器上本地安装所有 firebase 模拟器。 但是我 运行 单独设置我的函数模拟器,因为函数目录在不同的 project/location 中。 看来触发器没有被模拟,我收到下面的警告。除了 trigger/background 函数之外的所有功能似乎都可以正常工作。

有什么解决办法吗?

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:/cusomer/customer-web-app/

我可以 运行 位置 2 中的所有模拟器都可以,但函数模拟器除外,因为没有函数目录。 所以我 运行 在函数文件夹的位置 1 中添加以下内容: firebase emulators:start -- 仅功能

这很好用,因为它 运行 有 2 个模拟器实例。然而,trigger/background 函数没有 运行,因为它无法在不同的端口上找到 firestore 模拟器 运行ning。

解决这个问题的方法是使用符号 links。 这基本上是指向函数项目中另一个目录的快捷方式。

如果其他人想要这样做,Windows 上的命令是: mklink /D "R:\firestore-project\functions" "R:\cloud-functions-proj\functions"

您将需要运行命令提示符作为管理员。

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

注意: 您可以在创建符号 link 时指定绝对路径或相对路径。 相对是最好的选择,否则它不太可能在其他人的环境中工作。 运行 这在你想要创建的目录中 link:

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