close

[Fixed] Attempted import error: ‘firebase/app’ does not contain a default export (imported as ‘firebase’)

Today We are Going To Solve Attempted import error: ‘firebase/app’ does not contain a default export (imported as ‘firebase’) in reactjs. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

How to Fix Attempted import error: ‘firebase/app’ does not contain a default export (imported as ‘firebase’) Error?

  1. How to Fix Attempted import error: ‘firebase/app’ does not contain a default export (imported as ‘firebase’) Error?

    To Fix Attempted import error: ‘firebase/app’ does not contain a default export (imported as ‘firebase’) Error just Change firebase/app to firebase/compat/app. To solve this error you have to just change import firebase from 'firebase/app'; import 'firebase/firestore'; import 'firebase/auth'; to import firebase from 'firebase/compat/app'; import 'firebase/compat/firestore'; import 'firebase/compat/auth';

  2. Attempted import error: ‘firebase/app’ does not contain a default export (imported as ‘firebase’)

    To Fix Attempted import error: ‘firebase/app’ does not contain a default export (imported as ‘firebase’) Error just Use /compat folder in your imports. You have to use /compat folder in your imports to solve this error. import firebase from 'firebase/compat/app'; import 'firebase/compat/auth'; import 'firebase/compat/firestore';

Solution 1 : Change firebase/app to firebase/compat/app

To solve this error you have to just

change

import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';

to

import firebase from 'firebase/compat/app';
import 'firebase/compat/firestore';
import 'firebase/compat/auth';

Solution 2 : Use /compat folder in your imports

You have to use /compat folder in your imports to solve this error.

import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read These Solutions

Leave a Comment