4

I installed RNF from starter kit provided by Invertase. I am using RNF app, database, analytics, auth. Everything worked fine until I needed the auth module. It throws an error on app startup (on Android, haven't tried iOS):

    ...\node_modules\react-native\Libraries\Core\ExceptionsManager.js:86 
You've attempted to require '@react-native-firebase/auth' version '6.0.3', however, 
the '@react-native-firebase/app' module is of a different version (6.0.0).

    All React Native Firebase modules must be of the same version. 
Please ensure they match up in your package.json file and re-run yarn/npm install.

But I checked in package.json of all the modules are of version 6.0.3, and my package.json also looks good:

{
  "name": "meditationapp",
  "version": "6.0.3",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "run:android": "react-native run-android",
    "run:ios": "react-native run-ios --simulator=\"iPhone 11 Pro Max\"",
    "build:apk": "cd android && ./gradlew assembleRelease",
    "test": "jest",
    "prepare": "patch-package",
    "storybook": "start-storybook -p 7007"
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.6.2",
    "@react-native-community/netinfo": "^4.4.0",
    "@react-native-firebase/analytics": "6.0.3",
    "@react-native-firebase/app": "6.0.3",
    "@react-native-firebase/auth": "6.0.3",
    "@react-native-firebase/database": "6.0.3",
    "@typescript-eslint/eslint-plugin": "^2.3.3",
    "@typescript-eslint/parser": "^2.3.3",
    ...

Import in App.tsx:

import firebase from '@react-native-firebase/app'
import database from '@react-native-firebase/database'
import analytics from '@react-native-firebase/analytics'
import auth from '@react-native-firebase/auth'

Things I've tried:

  1. Delete node_modules and run npm install
  2. Installed v6.0.0 instead of 6.0.3
  3. Deleted android/app/build

Can't think of anything else to try, but the error does not go away. It's working fine with analytics and database, only auth is an issue.

Dmitri Borohhov
  • 1,513
  • 2
  • 17
  • 33

3 Answers3

3

I had the same problem. You should note that all packages of @react-native-firebase/... are equal to @react-native-firebase/app.

To solve this problem you need to update the relevant packages and then reset the npm cache:

  1. npm update @react-native-firebase/app
  2. npm update @react-native-firebase/analytics
  3. npm update @react-native-firebase/.. //all of the firebase packages (updated)

And finally reset the npm cache

  1. npm start -- --reset-cache
Srijwal R
  • 552
  • 9
  • 16
Mahdi Bashirpour
  • 17,147
  • 12
  • 117
  • 144
2

I created a project with:

npx @react-native-community/cli init --template=@react-native-firebase/template <name>

and I got this issue. But then I created a basic project like react-native init <name> and I installed

@react-native-firebase/app @react-native-firebase/auth

or any product, and the issue improved.

Das_Geek
  • 2,775
  • 7
  • 20
  • 26
  • I spent like two hours removing and installing node_modules and pods, but just `npm i --save ` worked like a charm. I dont know what to say... – tjeisenschenk Aug 24 '20 at 13:23
-1

Found this to be an issue with the caches.

  1. I deleted the npm cache and metro bundler cache (manually, on Windows the are located at C:\Users<user>\Appdata\Roaming)
  2. deleted the node_modules folder in the project
  3. Ran npm install

The project now has all RNF modules with version 6.0.3

Dmitri Borohhov
  • 1,513
  • 2
  • 17
  • 33