【发布时间】:2020-07-14 16:41:25
【问题描述】:
使用以下命令启动 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
更新
重新开始时,也会显示提到的错误。但是关闭端口使其工作。
在 package.json 的 scipts 部分下面添加
"kill": "npx kill-port 5000 5001 8080 8085 4000 9229"
然后运行
npm run kill
上面列出的所有端口都不是必需的。仅 8080 可能适用于您的情况,但我还有其他端口也被模拟器使用。
【问题讨论】:
-
听起来你正在运行另一个模拟器进程。
-
我尝试重启 VS 代码。但还是一样的情况。让我杀死端口看看。
-
@DougStevenson 还是一样的情况:|
-
npx kill-port 8080为我解决了这个错误:Port 8080 is not open on localhost, could not start firestore emulator
标签: firebase google-cloud-firestore firebase-cli