首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用特定的主机地址运行firebase模拟器?

如何使用特定的主机地址运行firebase模拟器?
EN

Stack Overflow用户
提问于 2021-09-12 15:15:53
回答 2查看 1K关注 0票数 1

我正在尝试将运行在物理设备上的颤振应用程序与本地计算机上的firebase模拟器连接起来,在此索夫中遵循以下步骤来实现此目的,但在运行以下命令时

代码语言:javascript
复制
firebase emulators:start --inspect-functions --export-on-exit ./test_data/ --import ./test_data/

firebase.json中使用此配置

代码语言:javascript
复制
{
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ],
    "source": "functions"
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "storage": {
    "rules": "storage.rules"
  },
  "emulators": {
    "auth": {
      "host": "0.0.0.0",
      "port": 9099
    },
    "functions": {
      "host": "0.0.0.0",
      "port": 5001
    },
    "firestore": {
      "host": "0.0.0.0",
      "port": 8080
    },
    "storage": {
      "host": "0.0.0.0",
      "port": 9199
    },
    "ui": {
      "enabled": true
    }
  }
}

它的结果是:

代码语言:javascript
复制
i  emulators: Starting emulators: auth, functions, firestore, storage
⚠  functions: You are running the functions emulator in debug mode (port=9229). This means that functions will execute in sequence rather than in parallel.
⚠  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: database, hosting, pubsub
✔  functions: Using node@14 from local cache.
i  emulators: Shutting down emulators.
i  functions: Stopping Functions Emulator
i  hub: Stopping emulator hub
⚠  firestore: Port 8080 is not open on 0.0.0.0, could not start Firestore Emulator.
⚠  firestore: To select a different host/port, specify that host/port in a firebase.json config file:
      {
        // ...
        "emulators": {
          "firestore": {
            "host": "HOST",
            "port": "PORT"
          }
        }
      }
i  emulators: Shutting down emulators.

这个错误是:

错误:无法启动修复模拟器,端口已被占用。

明显解

杀死任何使用端口8080的应用程序,更有可能是来自这个索夫的透水会话的防火墙仿真器。在关闭应用程序并再次运行命令之后,也会发生同样的错误。

备注

即使在本地网络中使用我的计算机地址而不是0.0.0.0,也无法工作,并导致相同的输出。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-09-18 11:15:07

为了运行命令,我不得不使用另一个端口,如8000,而不是8080,用于firebase.json中的firestor条目。

代码语言:javascript
复制
firebase emulators:start --inspect-functions --export-on-exit ./test_data/ --import ./test_data/

摘自这个github问题。此外,使用0.0.0.0将使firebase模拟器使用本地主机或本地网络中机器的ip地址。

尽管lsof -i :8080没有返回任何指示应用程序使用端口8080的结果

票数 2
EN

Stack Overflow用户

发布于 2021-09-12 16:10:11

我建议从"host": "0.0.0.0",中删除: firestore.json。[消]火基文件

这个命令帮助我杀死了运行在端口8080上的应用程序:

lsof -ti tcp:8080 | xargs kill

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69152738

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档