使用以下命令启动Firebase项目模拟器(使用云函数和FireStore)
firebase emulators:start
它运行成功,并给我一个路径连接到功能,并显示了一个本地主机的网址firestore太。
然后,为了执行我的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模拟器的日志:start
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可能在你的情况下工作,但我有其他端口也被模拟器使用。
5条答案
按热度按时间vm0i2vca1#
lsof
命令在windows powershell上不可用。更好的跨平台解决方案是:
npx kill-port 8080
ffscu2ro2#
在您的终端中键入以下内容,其中8080是您的端口号:
原因:Failed quitting the previous firebase emulator。
ni65a41a3#
firepit(可通过curl安装的独立CLI)有一个问题:#1868
将其安装为Node包可能会有帮助:
npm install -g firebase-tools
如果已经是这种情况,你可能应该在那里提交一个问题。
ekqde3dh4#
我关闭了终端,然后再次打开,再次启动命令,它的工作
vc6uscn95#
您可以找到PID和kill进程后: