Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module not found: Can't resolve 'firebase' in

After: npm i firebase

I'am importing firebase from firebase itself & not from a file

import firebase from 'firebase'; >in firebase.js file<

error in terminal>> ./src/firebase.js Module not found: Can't resolve 'firebase' in 'C:\Users\Home\Documents\dsn\e\Documents..........'

like image 436
Digamber negi Avatar asked Dec 30 '22 13:12

Digamber negi


1 Answers

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

like image 73
Dharmaraj Avatar answered Jan 11 '23 05:01

Dharmaraj