question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AuthModule)[AuthService -> AuthService -> AngularFirestore -> InjectionToken

See original GitHub issue

Angular: 13.0.3

Firebase: 9.4.0

AngularFire: 7.2.0

After upgrade angularfire 6 to 7 i got error

ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AuthModule)[AuthService -> AuthService -> AngularFirestore -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options]

simple if i can it any component constructor

private firebaseAuth: AngularFireAuth, or

private angularFirestore: AngularFirestore,

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:14

github_iconTop GitHub Comments

10reactions
simonbarbascucommented, Jul 26, 2022

Hi! This works for me. I put this in app.module.ts

import { FIREBASE_OPTIONS } from ‘@angular/fire/compat’;

@NgModule({ … providers: [ { provide: FIREBASE_OPTIONS, useValue: environment.firebaseConfig } ], })

8reactions
fkolarcommented, Dec 2, 2021

I see this pretty chaotic. The samples are so out of date and one cannot really follow them. I am getting the same errors.

I was able to initialize my module like this, and I try to stay our of compact/ package as it gives tons of errors.

import {initializeApp, provideFirebaseApp} from '@angular/fire/app';
import {connectFirestoreEmulator, getFirestore, provideFirestore} from '@angular/fire/firestore';
import {connectStorageEmulator, getStorage, provideStorage} from '@angular/fire/storage';
import {Auth, connectAuthEmulator, getAuth, provideAuth} from '@angular/fire/auth';


provideAuth(() => {
      const auth = getAuth();
      if (environment.useEmulators) {
        connectAuthEmulator(auth, 'http://localhost:9099', {disableWarnings: true});
      }
      auth.useDeviceLanguage();
      setPersistence(auth, indexedDBLocalPersistence);
      return auth;
    }),

I am not really sure which API or which documentation should I follow

https://github.com/angular/angularfire/blob/master/site/src/auth/route-guards.md or https://github.com/angular/angularfire/blob/master/docs/auth/router-guards.md

If I use the one from /site/ then it is also out of sync with latest code as this import is invalid.

import { AngularFireAuthGuard } from '@angular/fire/auth-guard';
Read more comments on GitHub >

github_iconTop Results From Across the Web

NullInjectorError: No provider for InjectionToken angularfire2 ...
The fix is actually really simple... in your app.module.ts. import import { FIREBASE_OPTIONS } from '@angular/fire/compat';.
Read more >
Uncaught (in promise): NullInjectorError: R3InjectorError ...
ERROR Error : Uncaught (in promise): NullInjectorError: R3InjectorError(AuthModule)[AuthService -> AuthService -> AngularFirestore -> ...
Read more >
NG0201: No provider for {token} found! - Angular
You see this error when you try to inject a service but have not declared a corresponding provider. A provider is a mapping...
Read more >
EXCEPTION: Error: Uncaught (in promise): No provider for ...
I'm stuck on this one error. I'm not sure what I'm doing wrong, or if it's some issue with beta 12 of the...
Read more >
Ionic 4 : Error: Uncaught (in promise): NullInjectorError
Ionic 4 : Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[AngularFireAuth -> InjectionToken angularfire2.app.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found