问题
I'm trying to serve firebase functions locally, but when I run firebase serve
or firebase emulators:start
the error message is: "Port 5000 is not open, could not start functions emulator."
I'm using Windows 10, so I've tried to change the port number, check if the port is blocked by Firewall and I create a new rule in Firewall to ports 5000-5010 but none of this approaches worked for me.
回答1:
A similiar problem has recently been reported in the official github repo: https://github.com/firebase/firebase-tools/issues/1606.
It is caused by a bug in a dependency (node portfinder), as you can see here. https://github.com/http-party/node-portfinder/pull/86
A quick fix to edit it might be to use the old version of node portfinder (v 1.0.21). Alternatively, you can do it by editing node_modules/firebase-tools/lib/emulator/controller.js
and changing yield pf.getPortPromise({ port, stopPort: port })
to yield pf.getPortPromise({ port, stopPort: port + 1 })
.
EDIT:
As suggested by Mladen Skrbic, in order to find the firebase-tools
folder, you should run npm root -g
and find the firebase-tools
folder in there.
This should fix the issue!
回答2:
Instead of latest firebase-functions(which is 3.2.0 currently), forcing it to stay at 3.0.2 solved in my case.
"dependencies": {
"firebase-admin": "^8.2.0",
"firebase-functions": "3.0.2",
...
}
(Also I am using firebase-tools version 7.0.2 atm, didnt check it with latest. If it doesnt work try reverting firebase-tools to 7.0.2)
回答3:
where is? node_modules/firebase-tools/lib/emulator/controller.js I cannot find "firebase-tools" folder in node_modules. I able to find only firebase-funstions and firebase-admin.
回答4:
This worked for me.
Just restart your system.
回答5:
A quick fix npm i -g firebase-tools@7.8.0
回答6:
The same error is happening with me too
Error: Port 5001 is not open, could not start functions emulator.
I tried using version 6.12.0
and got type errors.
回答7:
SOLUTION TO: Firebase serve error: Port 5000 is not open. Could not start functions emulator
If you get one of the following error messages when you run Firebase, you can easily resolve the problem by switching to another version of Firebase tools.
Port 5000 is not open, could not start functions emulator.
If you are using version 6 of Firebase Tools, you might switch to latest version (6.12.0), or you might try v7.2.2. To change to Firebase Tools version run to following node package manager command.
npm install -g firebase-tools@6.12.0
来源:https://stackoverflow.com/questions/57537355/firebase-serve-error-port-5000-is-not-open-could-not-start-functions-emulator