0

I followed one of the tutorial on React Native and got stopped in this error.
I used expo for my project. I used
expo install firebase

to install firebase in the project. When I run the project

expo start -c

I get the following error

Failed to compile.
C:/Users/*****/Desktop/*****/Apps/React Native/******/App.js
Module not found: Can't resolve 'firebase' in 'C:\Users\****\Desktop\*****\Apps\React Native\*****'

enter image description here

EDIT:
Here's the code

    import * as firebase from "firebase";
const firebaseConfig = {
  apiKey: "**********",
  authDomain: "************",
  projectId: "****************",
  storageBucket: "************",
  messagingSenderId: "***************",
  appId: "********************",
  measurementId: "***********",
};

if (firebase.apps.length === 0) {
  firebase.initializeApp(firebaseConfig);
}

Can anyone help to resolve this issue ?
Thanks !

5
  • can you provide more information like the import statements in App.js Jan 21, 2021 at 7:00
  • How are you importing firebase?
    – b3lg1c4
    Jan 21, 2021 at 7:08
  • Thanks ! I am importing firebase by import * as firebase from "firebase";
    – Ajit Kumar
    Jan 21, 2021 at 7:17
  • Follow this link you can get more information And Find your Actual solution.
    – Sajib saha
    Jan 21, 2021 at 7:54
  • Thanks ! Can you check the updated question
    – Ajit Kumar
    Jan 21, 2021 at 8:38

1 Answer 1

1

import * as firebase from 'firebase';

// Optionally import the services that you want to use
//import "firebase/auth";
//import "firebase/database";
//import "firebase/firestore";
//import "firebase/functions";
//import "firebase/storage";

// Initialize Firebase
const firebaseConfig = {
  apiKey: 'api-key',
  authDomain: 'project-id.firebaseapp.com',
  databaseURL: 'https://project-id.firebaseio.com',
  projectId: 'project-id',
  storageBucket: 'project-id.appspot.com',
  messagingSenderId: 'sender-id',
  appId: 'app-id',
  measurementId: 'G-measurement-id',
};

firebase.initializeApp(firebaseConfig);

Follow this link you can get more information And Find your Actual solution.

https://docs.expo.io/guides/using-firebase/

1
  • Thanks ! But I already did that !! Please see the updated question . I have added my code there
    – Ajit Kumar
    Jan 21, 2021 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.