Search code examples
firebasereact-nativefirebase-authentication

Authentication error: app._isFirebaseServerApp is not a function (it is undefined)


I have this Problem in main app but working on another project. When I run the relevant part in app.js alone, it gives the same error (just like in the other project). I use expo. Also my package.json:

  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@expo/metro-runtime": "~3.1.3",
    "@firebase/app": "^0.9.29",
    "@firebase/auth": "^1.6.2",
    "@firebase/database": "^1.0.3",
    "@react-native-async-storage/async-storage": "^1.23.1",
    "@react-native-community/masked-view": "^0.1.0",
    "@react-native-firebase/app": "^18.7.3",
    "@react-native-firebase/auth": "^18.7.3",
    "@react-navigation/bottom-tabs": "*",
    "@react-navigation/native": "6.0.0",
    "@react-navigation/native-stack": "^6.9.12",
    "@react-navigation/stack": "^6.3.16",
    "@types/react": "~18.2.14",
    "expo": "~50.0.14",
    "expo-constants": "~14.4.2",
    "expo-status-bar": "~1.11.1",
    "firebase": "^10.11.1",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.73.6",
    "react-native-dropdown-picker": "^5.4.6",
    "react-native-firebase": "^5.6.0",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-paper": "*",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-vector-icons": "^10.0.3",
    "react-native-web": "~0.19.6",
    "react-navigation": "*",
    "react-navigation-stack": "*"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "react-native-modal": "^13.0.1"
  },
  "private": true
}

problem

When I run the relevant part in app.js alone, it gives the same error (just like in the other project).


Solution

  • You are mixing use of the Firebase Web Client SDK (firebase) and React-Native-Firebase (@react-native-firebase). You almost certainly do not want to be doing that. Here is an article (disclosure: I wrote it) describing the differences.

    Additionally, when you install the Firebase Web Client SDK (npm i firebase) you do NOT need to install its sub-components (@firebase/app, @firebase/auth, etc.)

    Looking at the stack trace that comes with that error message, you should see where in your own code you are calling an API which leads to that error. In the future, providing a full stack trace rather than just an error message is way more helpful. Even more helpful would be for you to track down where in your code the error is being thrown from, and then share with us a snippet of that code.