firebase - 无法使用 exec 连接到 Firebase 模拟器套件

标签 firebase google-cloud-firestore firebase-cli

使用以下命令启动 firebase 项目模拟器(使用云功能和 firestore)

firebase emulators:start

它运行成功,并为我提供了连接到功能的路径,并显示了 firestore 的本地主机 URL。

然后,要执行我的笑话测试,请运行以下命令
firebase emulators:exec --only firestore jest

根据文档,要连接到本地 firstore,我们需要使用 exec。但它抛出低于错误。
i  emulators: Starting emulators: firestore
⚠  emulators: emulator hub unable to start on port 4400, starting on 4401
✔  hub: emulator hub started at http://localhost:4401
i  Shutting down emulators.
i  Stoppping emulator hub
⚠  Port 8080 is not open on localhost, could not start firestore emulator.
i  To select a different host/port for the emulator, update your "firebase.json":
    {
      // ...
      "emulators": {
        "firestore": {
          "host": "HOST",
          "port": "PORT"
        }
      }
    }
i  Shutting down emulators.
Error: Could not start firestore emulator, port taken.

每次运行 exec 命令时都会抛出此错误。有人可以指出可能有什么问题吗?

编辑:来自 firebase 模拟器的日志:开始
firebase emulators:start
i  emulators: Starting emulators: functions, firestore, hosting, pubsub
✔  hub: emulator hub started at http://localhost:4400
⚠  Your requested "node" version "8" doesn't match your global version "10"
✔  functions: functions emulator started at http://localhost:5001
i  firestore: Serving ALL traffic (including WebChannel) on http://localhost:8080
⚠  firestore: Support for WebChannel on a separate port (8081) is DEPRECATED and will go away soon. Please use port above instead.
i  firestore: firestore emulator logging to firestore-debug.log
✔  firestore: firestore emulator started at http://localhost:8080
i  firestore: For testing set FIRESTORE_EMULATOR_HOST=localhost:8080
i  hosting[website]: Serving hosting files from: public
✔  hosting[website]: Local server: http://localhost:5000
i  hosting[admin]: Serving hosting files from: public
✔  hosting[admin]: Local server: http://localhost:5005
i  hosting[b2b]: Serving hosting files from: public
✔  hosting[b2b]: Local server: http://localhost:5006
i  hosting[b2c]: Serving hosting files from: public
✔  hosting[b2c]: Local server: http://localhost:5007
i  hosting[sdk]: Serving hosting files from: public
✔  hosting[sdk]: Local server: http://localhost:5008
✔  hosting: hosting emulator started at http://localhost:5000
i  pubsub: pubsub emulator logging to pubsub-debug.log
✔  pubsub: pubsub emulator started at http://localhost:8085

最佳答案

在您的终端中输入以下内容,其中 8080 是您的端口号:

lsof -ti tcp:8080 | xargs kill
原因: Failed quitting the previous firebase emulator

关于firebase - 无法使用 exec 连接到 Firebase 模拟器套件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60996172/

相关文章:

javascript - 如何在reactjs中上传到Firebase存储之前调整图像大小

Firebase 项目 ID 必须为小写

firebase - 如何在启动时解决 Firebase CLI 错误

火力基地。在实时数据库窗口中找不到“规则”选项卡。为什么?

angular - Firebase 和外部 API 404(Firebase 函数)

android - Firebase:根据时差允许访问(服务器端时间)

android - 将其与 Firebase 链接后 Flutter 卡住了

ios - 如何仅在设置数据后调用完成处理程序?

firebase - Flutter Firestore 查询 2 个集合

firebase - 如何写入firestore模拟器?