Home > front end >  build fails after installing firebase and referencing it through imports - firebase could not be fou
build fails after installing firebase and referencing it through imports - firebase could not be fou

Time:10-29

Error:

error Unable to resolve module https://www.gstatic.com/firebasejs/9.1.3/firebase-app.js from xxx\node_modules\firebase\firebase-auth.js: https://www.gstatic.com/firebasejs/9.1.3/firebase-app.js could not be found within the project or in these directories:
  node_modules

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
> 1 | import { _getProvider, _registerComponent, SDK_VERSION, registerVersion, getApp } from 'https://www.gstatic.com/firebasejs/9.1.3/firebase-app.js';

What i have tried:

  • follow error instructions; no change
  • follow some similar github issues
  • checked out similar stackoverflow issues

Additional info:

  • I had similar module resolution errors before, but for the most time simply restarting metro fixed my issue - with this one it does not disappear.

My code:

// Import the functions you need from the SDKs you need

import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth"
import {
    FIREBASE_API_KEY,
    FIREBASE_AUTH_DOMAIN,
    FIREBASE_PROJECT_ID,
    FIREBASE_APP_ID,
    FIREBASE_MESSAGING_SENDER_ID,
    FIREBASE_STORAGE_BUCKET
} from "@env";

// https://firebase.google.com/docs/web/setup#available-libraries

const firebaseConfig = {
    apiKey: FIREBASE_API_KEY,
    authDomain: FIREBASE_AUTH_DOMAIN,
    projectId: FIREBASE_PROJECT_ID,
    storageBucket: FIREBASE_STORAGE_BUCKET,
    messagingSenderId: FIREBASE_MESSAGING_SENDER_ID,
    appId: FIREBASE_APP_ID
};

export const FirebaseApplication = initializeApp(firebaseConfig);
export const FireBaseAuthentication = getAuth(FirebaseApplication)

CodePudding user response:

You should use react-native-firebase library and follow the instructions to install it.

https://rnfirebase.io/

https://github.com/invertase/react-native-firebase

  • Related