Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

firebase.initializeApp() does not expose firestore() function #1091

Closed
ghost opened this issue Aug 5, 2018 · 10 comments
Closed

firebase.initializeApp() does not expose firestore() function #1091

ghost opened this issue Aug 5, 2018 · 10 comments

Comments

@ghost
Copy link

ghost commented Aug 5, 2018

[REQUIRED] Describe your environment

  • Operating System version: mac OS 10.13.4
  • Browser version: N/A (react native app)
  • Firebase SDK version: 5.0.3
  • Firebase Product: firestore

[REQUIRED] Describe the problem

Calling firebase.initializeApp(config).firestore() errors out with undefined is not a function. This occurs whenever I try to run the react native application. However if I run the same code directly with node this error does not occur. Something confusing is happening when it is run within the react native project / Android simulator.

Steps to reproduce:

  • Use react-native-cli to initialize a new app.
  • Add firebase@5.0.3 to the project.
  • Call firebase.initializeApp(config).firestore() with a valid config object.

Relevant Code:

import Firebase from 'firebase';

const config = {
    apiKey: "...",
    authDomain: "...",
    databaseURL: "...",
    projectId: "...",
    storageBucket: "...",
    messagingSenderId: "...",
};

Firebase.initializeApp(config).firestore();
@mikelehen
Copy link
Contributor

Can you try using the latest SDK (5.3.1)?

If that still doesn't work, I'm curious if adding this helps:

import 'firebase/firestore';

Thanks!

@ghost
Copy link
Author

ghost commented Aug 9, 2018

I tried creating a clean project (using react-native-cli). By simply importing firebase the app fails to launch with:

image

Here's a gist of the code and package.json that caused the above error: https://gist.github.com/erewh0n/d4703727343a06f37151905fa0496e7a

When I change the import to import 'firebase/firestore'; the error is:
image

@jshcrowthe
Copy link
Contributor

jshcrowthe commented Aug 14, 2018

@erewh0n thanks for helping us dig into this. The first error you are seeing is due to the Polyfills that firebase loads to ensure that the environment is stable. The reasoning is outlined here: #871 (comment).

Can you get me an example of your issue that I can dig into this some more?

@Yingi
Copy link

Yingi commented Sep 10, 2018

I have thesame issue as @erewh0n

@Yingi
Copy link

Yingi commented Sep 10, 2018

Actually mine is a bit complex because, It ony gives the error when i do the import in my App.js file

When i do the import

import Firebase from 'firebase';

It works in other screens of my app, but doesnt work in the App.js which is the entry level of the app

@MohitOpenxcel
Copy link

MohitOpenxcel commented Oct 31, 2018

I am using com.google.firebase:firebase-admin:6.5.0. I have set following rules in firebase.

{
"rules": {
".read": true,
".write": true
}
}
Still I am getting

PersistentConnection: pc_0 - Authentication failed: permission_denied (Access denied.).

@mikelehen
Copy link
Contributor

If any of you are still running into issues, please open a new issue with full repro instructions so that we can investigate. Thanks!

@bbangert
Copy link

@mikelehen I'm hitting this as well. I referenced our issue here which @Zirak tracked down to the @firebase/firestore not having a select method, while @google-cloud/firestore does have a select method on its Query object. Unfortunately only this library seems to have a testing app allowing one to use the emulator with Firestore, and there's a feature mismatch where the Javascript library does not have select.

@ryanpbrewster
Copy link
Contributor

It's possible to use the @google-cloud/firestore SDK with the Firestore emulator (as of version 2.1.0!). There's an example of how to get started in this PR: googleapis/nodejs-firestore#654

@bbangert
Copy link

@ryanpbrewster Great, thanks a lot!

@firebase firebase locked and limited conversation to collaborators Oct 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants