【发布时间】:2021-09-12 15:15:53
【问题描述】:
我正在尝试将我在物理设备上运行的颤振应用程序与本地计算机上的 firebase 模拟器连接起来,按照SOF 中的这些步骤进行操作,但是在运行此命令时
firebase emulators:start --inspect-functions --export-on-exit ./test_data/ --import ./test_data/
在firebase.json 中使用此配置:
{
"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
}
}
}
它会产生这个输出:
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.
这个错误:
错误:无法启动 Firestore 模拟器,端口已占用。
明显的解决方案
从SOF 终止使用端口 8080 的任何应用程序,更有可能是之前会话的 Firestore 模拟器。杀死应用程序并再次运行命令后,出现同样的错误。
注意
即使在本地网络中使用我的机器地址而不是 0.0.0.0 也不起作用并导致相同的输出。
【问题讨论】: