使用以下命令启动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
答案 0 :(得分:3)
lsof
命令在 windows powershell 上不可用。
更好的跨平台解决方案是:npx kill-port 8080
答案 1 :(得分:2)
答案 2 :(得分:0)
firepit(可通过curl安装的独立CLI)存在一个问题:#1868
将其安装为Node软件包可能会有所帮助:npm install -g firebase-tools
如果已经是这种情况,则可能应该在此处提出问题。
答案 3 :(得分:0)
我关闭终端,然后再次打开它,再次启动命令,它可以工作