Failed to compile node module when i try to export db from firebase

Viewed 83

i am trying to access my data base from google firestore which is as follows


 import firebase from "firebase";
 const firebaseApp = firebase.initializeApp({
    apiKey: "...",
    authDomain: "...",
    ....
});

const db = firebaseApp.firestore();

export default db;

when i try to export this db to my other functional components i keep getting this error

please look at the image which i am getting


./node_modules/@firebase/firestore/dist/esm5/prebuilt-db9cc925-eb007c37.js Attempted import error: 'FetchXmlHttpFactory' is not exported from '@firebase/webchannel-wrapper' (imported as 'v').


i tried to

  1. re install the node modules

  2. also tried updating and removing node still

but still i keep getting this error. please help me out with this, been stuck here for almost a day

1 Answers

Look like you have not imported correctly

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

const firebaseApp = firebase.initializeApp({
        apiKey: "...",
        authDomain: "...",
        ....
    });
    
const db = firebaseApp.firestore();
    
export default db;

Also make sure to install right package npm i firebase

Related