Firebase 9 - Export 'initializeApp' was not found in 'firebase/app'

Viewed 491

After upgrading to firebase 9, i am getting trouble importing some functions that used to work on firebase 8. Of course i read the docs and refactored the code but this error keeps popping up, this also happens for other imports.

My imports look like this

import { initializeApp } from 'firebase/app'
import { getDatabase } from 'firebase/database'
import { getAuth, signInWithCustomToken, onAuthStateChanged } from 'firebase/auth'

The error I get is:

Export 'initializeApp' was not found in 'firebase/app'


I also tried using the compat libraries

import { initializeApp } from 'firebase/compat/app'
import { getDatabase } from 'firebase/compat/database'
import { getAuth, signInWithCustomToken, onAuthStateChanged } from 'firebase/compat/auth'

But i still get

WARNING "export 'initializeApp' was not found in 'firebase/compat/app'

This also happens for my other imports.

Any help?

1 Answers

The compat version uses the V8 name-spaced syntax and does not require separate imports for every function like in newer modular/functional syntax:

import firebase from 'firebase/compat/app'
import 'firebase/compat/database'
import 'firebase/compat/auth'

// import { getAuth } from 'firebase/auth' <-- Modular version only

If you are using compat version then make sure you are following the namespaced version tab in the documentation:

enter image description here

Related