Ayy*_*ppa 10 firebase google-cloud-firestore firebase-cli
Started firebase project emulators (which uses cloud functions and firestore) with below command
firebase emulators:start
Run Code Online (Sandbox Code Playgroud)
It runs successfully and gives me a path to connect to the functions and shows a local host url for firestore too.
Then, to execute my jest tests, ran the below command
firebase emulators:exec --only firestore jest
Run Code Online (Sandbox Code Playgroud)
As per the documentation, to connect to local firstore, we need to use exec. But its throwing below error.
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.
Run Code Online (Sandbox Code Playgroud)
This error is thrown everytime when I run exec command. Can someone point out what could be wrong?
Edit: Logs from firebase emulators: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
Run Code Online (Sandbox Code Playgroud)
Update
With a fresh start also the mentioned error is shown. But killing the port made it work.
Added below in scipts part of package.json
"kill": "npx kill-port 5000 5001 8080 8085 4000 9229"
Run Code Online (Sandbox Code Playgroud)
and run
npm run kill
Run Code Online (Sandbox Code Playgroud)
Here all above listed ports aren't reqired. Just 8080 might work in your case but I have other ports too being used by the emulator.
小智 11
在您的终端中输入以下内容,其中 8080 是您的端口号:
lsof -ti tcp:8080 | xargs kill
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4352 次 |
| 最近记录: |