问题描述
我正在尝试在本地运行 Firebase。我有作为模拟器运行的函数和 firestore。
当我保存对我的任何文件的更新时,它会再次运行 firebase,它应该如此。但是,它会尝试在之前运行的同一端口上再次运行模拟器,并且由于该端口仍处于活动状态,因此会引发错误 Could not start Firestore Emulator,port taken
,表明该端口已被占用。我尝试使用以下方法为 Firestore 模拟器添加特定端口:
"emulators": {
"firestore": {
"port": "2525"
}
}
但这并没有真正改变这样一个事实,即当我保存时它试图在端口 2525 上重新运行模拟器,但不能,因为它已经被占用了。
要从日志中添加更多详细信息:
i emulators: Starting emulators: functions,firestore
⚠ emulators: It seems that you are running multiple instances of the emulator suite for project my-app. This may result in unexpected behavior.
⚠ functions: The following emulators are not running,calls to these services from the Functions emulator will affect production: auth,database,hosting,pubsub
✔ functions: Using node@12 from host.
i emulators: Shutting down emulators.
i functions: Stopping Functions Emulator
i hub: Stopping emulator hub
⚠ firestore: Port 2525 is not open on localhost,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.
Error: Could not start Firestore Emulator,port taken.
Having trouble? Try firebase [command] --help
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ serve: `npm run build && firebase emulators:start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mememe/.npm/_logs/2021-01-11T21_21_03_874Z-debug.log
[nodemon] app crashed - waiting for file changes before starting...
我该怎么办?
更新
目前,我可以继续工作的唯一方法是触发此脚本命令 npm run build && npx kill-port 2525 && firebase emulators:start
,以便它在重新加载时终止 firestore 模拟器端口。显然这是愚蠢的,所以我期待 Firebase 团队或知道如何处理这个问题的人的来信。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)