google-cloud-firestore - 当函数目录位于不同的项目/位置时运行 firebase 模拟器
问题描述
我在 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:/客户/客户云项目/功能
- R:/客户/客户网络应用程序/
我可以运行位置 2 中的所有模拟器,除了函数模拟器,因为没有函数目录。所以我在函数文件夹的位置 1 中运行以下命令:firebase emulators:start --only functions
这很好用,因为它运行了 2 个模拟器实例。但是,触发器/背景功能不会运行,因为它找不到在不同端口上运行的 firestore 模拟器。
解决方案
解决方案是使用符号链接。这基本上是位于函数项目中的另一个目录的快捷方式。
如果其他人想这样做,Windows 上的命令是: mklink /D "R:\firestore-project\functions" "R:\cloud-functions-proj\functions"
您需要以管理员身份运行命令提示符。
有关更多详细信息,请参阅我的问题: https ://github.com/firebase/firebase-tools/issues/3092#issuecomment-771159457
注意:您可以在创建符号链接时指定绝对或相对路径。相对是最好的选择,否则它不太可能在其他人的环境中工作。在要创建链接的目录中运行它:
mklink /D "models" "..\..\..\myapp\src\app\models"
推荐阅读
- c# - 下载不带 url C# 前缀的图片
- php - 在 PHP 中将 mysql 列中的数据显示为行
- javascript - 在 javascript 中通过 EventSource 创建的提要上的事件侦听器
- ruby-on-rails - 提交表单时出现“没有路线匹配 [POST]”错误
- asp.net - 使用参数时报告查看器错误
- javascript - 反应其余国家 - 添加有关国家/地区的信息
- angular - Angular + Firebase 令牌的持久性
- ios - 检查卡是否已添加到 PassKit 库
- powershell - 创建或更新策略的输入格式不正确(PowerShell 脚本中的 .json 模板)
- javascript - 我想在 onpopstate 事件上写一些代码而不刷新页面