Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

ErrorCorner

ErrorCorner Logo ErrorCorner Logo

ErrorCorner Navigation

  • Home
  • Contact Us
  • About Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Contact Us
  • About Us
Home/ Questions/Q 59
Next
Answered
Kenil Vasani
Kenil Vasani

Kenil Vasani

  • 646 Questions
  • 567 Answers
  • 77 Best Answers
  • 26 Points
View Profile
  • 0
Kenil Vasani
Asked: November 19, 20202020-11-19T06:42:34+00:00 2020-11-19T06:42:34+00:00In: Javascript

Upgrade to Firebase JS 8.0.0: Attempted import error: ‘app’ is not exported from ‘firebase/app’ (imported as ‘firebase’)

  • 0

After upgrading to 8.0.0, I get the following error:

Attempted import error: ‘initializeApp’ is not exported from ‘firebase/app’ (imported as ‘firebase’).

My import looks like this:

import * as firebase from "firebase/app"
firebase.initializeApp({ ... })

TypeScript also complains:

Property ‘initializeApp’ does not exist on type ‘typeof import(“/path/to/my/file”)’. ts(2339)

How do I fix this?

firebasejavascripttypescript
  • 1 1 Answer
  • 150 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    1 Answer

    • Voted
    1. Kenil Vasani

      Kenil Vasani

      • 646 Questions
      • 567 Answers
      • 77 Best Answers
      • 26 Points
      View Profile
      Best Answer
      Kenil Vasani
      2020-11-19T06:42:42+00:00Added an answer on November 19, 2020 at 6:42 am

      In version 8.0.0, the Firebase SDK had a breaking change in the way it handles exports:

      Breaking change: browser fields in package.json files now point to ESM bundles instead of CJS bundles. Users who are using ESM imports must now use the default import instead of a namespace import.

      Before 8.0.0

      import * as firebase from 'firebase/app'
      

      After 8.0.0

      import firebase from 'firebase/app'
      

      Code that uses require('firebase/app') or require('firebase') will still work, but in order to get proper typings (for code completion, for example) users should change these require calls to require('firebase/app').default or require('firebase').default. This is because the SDK now uses typings for the ESM bundle, and the different bundles share one typings file.

      So, you will have to use the new ESM bundle default export:

      import firebase from "firebase/app"
      firebase.initializeApp({ ... })
      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    You must login to add an answer.

    Forgot Password?

    Sidebar

    Ask A Question
    • Popular
    • Kenil Vasani

      SyntaxError: invalid syntax to repo init in the AOSP code

      • 5 Answers
    • Kenil Vasani

      xlrd.biffh.XLRDError: Excel xlsx file; not supported

      • 3 Answers
    • Kenil Vasani

      Homebrew fails on MacOS Big Sur

      • 3 Answers
    • Kenil Vasani

      runtimeError: package fails to pass a sanity check for numpy ...

      • 3 Answers
    • Kenil Vasani

      Replicating claims as headers is deprecated and will removed from ...

      • 2 Answers

    Explore

    • Most Answered
    • Most Visited
    • Most Voted
    • Random

    © 2020-2021 ErrorCorner. All Rights Reserved
    by ErrorCorner.com