It seems like you intialized firestore correctly, i belive you have installed all needed dependenvies and librarys.
- Make sure your firebase setup is setup correctly and the service account has the right permissions
- If it runs locally but not on deployment check the environment variables if they may differ
- Debugging logs check the firebase logs for more detailed error messages, you can do that via the Firebase consle (helps a lot) there you'll probably find the error message helping you advance in your project