Dbl
Dbl

Reputation: 5894

build fails after installing firebase and referencing it through imports - firebase could not be found within the project or in these directories

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:

Additional info:

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)

Upvotes: 0

Views: 924

Answers (1)

Stepan Nikulenko
Stepan Nikulenko

Reputation: 653

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

https://rnfirebase.io/

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

Upvotes: 1

Related Questions