Search code examples
firebasefirebase-authenticationangular14

What is the Firebase Authentication import for Angular 14


https://github.com/angular/angularfire/blob/HEAD/docs/auth/getting-started.md#5-getting-started-with-firebase-authentication

I'm trying to use new firebase.authGoogleAuthProvider() and I can't import firebase. I've installed:

 "dependencies": {
    "@angular/common": "^14.0.0",
    "@angular/core": "^14.0.0",
    "@angular/fire": "^7.4.1",
    "@angular/forms": "^14.0.0",
    "@angular/platform-browser": "^14.0.0",
    "@angular/platform-browser-dynamic": "^14.0.0",
    "@angular/router": "^14.0.0",
    "@ionic-native/google-plus": "^5.36.0",
    "@ionic-native/sign-in-with-apple": "^5.36.0",
    "@ionic/angular": "^6.1.9",
    "@jest/globals": "^28.1.1",
    "@microsoft/applicationinsights-web": "^2.8.5",
    "angularfire2": "^5.4.2",
    "cordova-plugin-googleplus": "^8.5.2",
    "cordova-plugin-sign-in-with-apple": "^0.1.2",
    "firebase": "^7.9.0",
    "rxjs": "~6.6.0",
    "tslib": "^2.2.0",
    "zone.js": "~0.11.4"
  },

Here's a screenshot of the node_modules/@firebase

enter image description here

Here's one of the node_modules/firebase

enter image description here

Somewhere I found that I should use this import but as you see, this path doesn't exist. Any suggestions?

import firebase from 'firebase/compat/app';


Solution

  • firebase/compat appeared only in firebase v9, i see you are using "firebase": "^7.9.0" in your package json so npm will install latest version prior to v8.

    To check installed firebase version - see package.json file inside node_modules/firebase directory.

    To use import firebase from 'firebase/compat/app'; as per your guides - update firebase version in your package.json file and rerun npm install. Latest version is 9.9.0 so it will be "firebase": "~9.9.0" or "firebase": "^9.9.0"

    More details at https://firebase.google.com/docs/web/modular-upgrade