Ajit Kumar
Ajit Kumar

Reputation: 417

Failed to compile. Module not found: Can't resolve 'firebase'


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 !

Upvotes: 0

Views: 1400

Answers (1)

Sajib saha
Sajib saha

Reputation: 371

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/

Upvotes: 1

Related Questions