无法使用EXEC连接到FireBase仿真器套件 [英] Unable to connect to firebase emulator suite with exec

查看:6
本文介绍了无法使用EXEC连接到FireBase仿真器套件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下命令启动了Firebase项目模拟器(使用云函数和FireStore)

firebase emulators:start

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

然后,为了执行我的JEST测试,运行了以下命令

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

更新

重新开始时,也会显示上述错误。但扼杀港口使其运转正常。

已在Package.json的scipts部分中添加

"kill": "npx kill-port 5000 5001 8080 8085 4000 9229"

并运行

npm run kill

此处不需要上面列出的所有端口。在您的情况下,可能只有8080端口可以工作,但我的模拟器也在使用其他端口。

推荐答案

lsof命令在Windows PowerShell上不可用。

更好的跨平台解决方案是:npx kill-port 8080

这篇关于无法使用EXEC连接到FireBase仿真器套件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆