'Error in usage of firebase in my react native expo project

Hey this is Shubham and i am 12 years old and i am an ardent learner of mobile app development with the cross platform language react native and i want to learn how to build a full stack social media application with the use of firebase as backend but i am facing errors frequently in firebase when i try to import * as firebase from 'firebase' it keeps throwing errors that says firebase module not found but i have already installed firebase in my expo project. so How can i use multiple services of firebase in my project.

(my code is correct but still i am facing error)



Solution 1:[1]

you should cheack your firebase version in package.json depencence in version 8 it should be some thing like this "firebase": "^8.2.3",

this is how you can import them

import * as firebase from "firebase";
import "@firebase/auth";
import "firebase/storage";
import "firebase/firestore";
const firebaseConfig = {
  apiKey: "....",
  authDomain: "..",
  projectId: "...",
  storageBucket: "...",
  messagingSenderId: "...",
  appId: "..",
};

firebase.initializeApp(firebaseConfig);
export default firebase;

if its version 9 you have to import them differently however, you can change the version in package.json to "^8.2.3" than do " npm install " in the terminal

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Xpaew andX