Module not found: Can’t resolve ‘firebase’ in

We Are Going To Discuss About Module not found: Can’t resolve ‘firebase’ in. So lets Start this Javascript Article.

Module not found: Can’t resolve ‘firebase’ in

How to solve Module not found: Can’t resolve ‘firebase’ in

npm i firebase now installs v9 Modular SDK so you cannot used the old imports. Try refactoring your code to this:
import { initializeApp } from 'firebase/app'; const firebaseConfig = { //... }; const app = initializeApp(firebaseConfig);
If you want to use older syntax then change your imports to compat libraries:
import firebase from "firebase/compat/app" import "firebase/compat/auth" import "firebase/compat/firestore" // other services is needed
You can read more about it in the documentation

Module not found: Can’t resolve ‘firebase’ in

npm i firebase now installs v9 Modular SDK so you cannot used the old imports. Try refactoring your code to this:
import { initializeApp } from 'firebase/app'; const firebaseConfig = { //... }; const app = initializeApp(firebaseConfig);
If you want to use older syntax then change your imports to compat libraries:
import firebase from "firebase/compat/app" import "firebase/compat/auth" import "firebase/compat/firestore" // other services is needed
You can read more about it in the documentation

Solution 1

npm i firebase now installs v9 Modular SDK so you cannot used the old imports. Try refactoring your code to this:

import { initializeApp } from 'firebase/app';

const firebaseConfig = {
  //...
};

const app = initializeApp(firebaseConfig);

If you want to use older syntax then change your imports to compat libraries:

import firebase from "firebase/compat/app"
import "firebase/compat/auth"
import "firebase/compat/firestore"
// other services is needed

You can read more about it in the documentation

Original Author Dharmaraj Of This Content

Solution 2

There should be no reason to downgrade to version 8 as version 9 provides a fully backward compatible import if you prefix the module import path with “compat”.

To use:

import firebase from "firebase/compat/app";
// Other libraries might need to also be prefixed with "compat":
import "firebase/compat/auth";

// Then you can then use the old interface, with version 9:
if (!firebase.apps.length) {
  firebase.initializeApp(clientCredentials);
}

Upgrade notes: https://firebase.google.com/docs/web/modular-upgrade

Original Author MrInvolved Of This Content

Solution 3

initializeApp is moved to firebase/app package in latetst version
so import from firebase/app.

Original Author akshay padmane Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment