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

Very persistent error [FLAMELINK] The "firestore" Firebase service could not be instantiated. #180

Closed
dankerk opened this issue Sep 3, 2021 · 4 comments

Comments

@dankerk
Copy link

dankerk commented Sep 3, 2021

Hi there,

I'm starting to get quite desperate to get the flamelink SDK to work.
Can you see what's causing this error?

[FLAMELINK] The "firestore" Firebase service could not be instantiated. Please ensure you have imported the package for this service.
TypeError: context.firebaseApp[serviceName] is not a function

At this point I'm quite sure firestore is already instantiated. Any help would be greatly appreciated.
I'm using Nextjs and trying to list the pages in the console just to get the basisc to work:

  useEffect(() => {
    getFlamelinkApp().content.get({ schemaKey: 'page' })
    .then((pages: any) => {
      console.log('All of your pages:', pages)
    })
    .catch((error: any) => console.log(error))
  }, []);
import 'flamelink/content'
import { getFirestore } from "firebase/firestore";
import { initializeApp } from 'firebase/app';
import { firebaseConfig } from '../settings/firebase.config';

const firebaseApp = initializeApp(firebaseConfig);
let flamelinkApp: any;

export function getFlamelinkApp() {
  if (!flamelinkApp) {
    getFirestore(); // attempting to make sure firestore is loaded before initialising flamelink

    flamelinkApp = flamelink({
      firebaseApp,
      env: 'production',
      locale: 'en-US',
      dbType: 'cf' // optional, defaults to `rtdb` - can be 'rtdb' or 'cf' (Realtime DB vs Cloud Firestore)
    })
  }
  return flamelinkApp;
}```

@dewetvdm
Copy link
Contributor

dewetvdm commented Sep 3, 2021

Hi,

Which version of the Firebase SDK are you using?

Flamelink does not v9 of the Firebase SDK (modular importing)

@dankerk
Copy link
Author

dankerk commented Sep 3, 2021

Aaaah nooo haha! Then that must be it... I'm using V9

This is my setup at the moment:

"dependencies": {
"@material-ui/core": "^4.12.3",
"firebase": "^9.0.1",
"firebase-admin": "^9.11.1",
"flamelink": "^1.0.0-alpha.34",
"install": "^0.13.0",
"next": "11.1.0",
"npm": "^7.21.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"styled-components": "^5.3.1"
},
"devDependencies": {
"@types/react": "17.0.19",
"@types/styled-components": "^5.1.13",
"babel-plugin-styled-components": "^1.13.2",
"eslint": "7.32.0",
"eslint-config-next": "11.1.0",
"generate-react-cli": "^7.0.4",
"sass": "^1.38.1",
"typescript": "4.4.2"
}

Thanks for the super fast reply by the way

@dewetvdm
Copy link
Contributor

dewetvdm commented Sep 3, 2021

Can you install Firebase SDK v8

npm i --save firebase@8.10.0

and then follow this guide?

https://flamelink.github.io/flamelink-js-sdk/#/getting-started?id=creating-your-flamelink-app-instance

@dankerk
Copy link
Author

dankerk commented Sep 3, 2021

That made all the difference! Thanks a lot.

Might be nice to add to the prerequisites which versions of firebase sdk will work with flamelink.
With V9 released I think more people might run into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants