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.

[AngularFirestore -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options]:

See original GitHub issue

Version info

Angular CLI: 12.2.7 Node: 14.16.0 Package Manager: npm 6.14.11 OS: win32 x64

Angular: 12.2.7 … animations, cli, common, compiler, compiler-cli, co … platform-browser, platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.1200.5 @angular-devkit/build-angular 12.2.7 @angular-devkit/core 12.2.7 @angular-devkit/schematics 12.2.7 @angular/fire 7.0.4 rxjs 6.6.7
typescript 4.3.5

How to reproduce these conditions

I tried to u firebase whi modular lazy load and call fireAngular from a service but when i call the route i got this error : NullInjectorError: R3InjectorError(DashboardModule)[AngularFirestore -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options]: NullInjectorError: No provider for InjectionToken angularfire2.app.options!

Failing test unit, Stackblitz demonstrating the problem

Steps to set up and reproduce

Sample data and security rules

Debug output

** Errors in the JavaScript console **

** Output from firebase.database().enableLogging(true); **

** Screenshots ** image image image image

I have tried to provide angularFire in my app.module and as well in my dashboard lazy module but nothing works

Expected behavior

Actual behavior

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
jagdishjadejacommented, Sep 27, 2021

i am also facing same issue can someone provide solution for this issue ?

4reactions
cevariscommented, Oct 12, 2021

@jamesdaniels are you saying we cannot use compat imports in Components when using provider* functions in Modules?

If so, how else can we import the follolwing

import {
    AngularFirestore,
    AngularFirestoreDocument
} from '@angular/fire/compat/firestore';

EDIT I got this working by converting all angularfire imports to use compat paths.

app.module.ts

import { AngularFireModule } from '@angular/fire/compat';
import { AngularFirestoreModule } from '@angular/fire/compat/firestore';
import { AngularFireStorageModule } from '@angular/fire/compat/storage';
...
@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [
    BrowserModule.withServerTransition({ appId: 'serverApp' }),
    AngularFireModule.initializeApp(environment.firebaseConfig),
    AngularFirestoreModule.enablePersistence(),
    AngularFireStorageModule,
    ....

And in my component, I used the following imports

import { AngularFireAuth } from '@angular/fire/compat/auth';
import {
  AngularFirestore,
  AngularFirestoreDocument
} from '@angular/fire/compat/firestore';
...

See upgrade guide for now.

Most developers can stop here for now as the new API isn’t feature complete.

Apparently, the new API is not even feature complete yet…

Read more comments on GitHub >

github_iconTop Results From Across the Web

No provider for InjectionToken angularfire2.app.options
You're not initializing your app correctly. When you import the AngularFireModule , you need to initialize there:
Read more >
angular/angularfire2 - Gitter
Hey guys I am getting No provider for InjectionToken angularfire2.app.options in my test. I have added AngularFirestore as a provider in testBed. Aleksander....
Read more >
Angular 9 firebase service: No provider for InjectionToken ...
I'm trying to learn unit testing via Jest and I'm having trouble with AngularFire2 in Angular 9 in a Server-side Rendered app (SSR)...
Read more >
Angular Prototyping: Firebase Emulator with Cypress - ITNEXT
Configures a firebase app with the firestore & auth emulator ... NullInjectorError: No provider for InjectionToken angularfire2.app.options.
Read more >
AngularFire - NullInjectorErrorの対処法 - Qiita
ERROR NullInjectorError: R3InjectorError(AppModule)[AngularFireDatabase -> InjectionToken angularfire2.app.options -> InjectionToken ...
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