Angularfire: Error: No provider for InjectionToken FirebaseAppConfigToken!

Created on 12 May 2017  Â·  20Comments  Â·  Source: angular/angularfire

Version info

Angular:
4.1.1

Firebase:
3.9.0

AngularFire:
4.0.0-rc0

Other (e.g. Ionic/Cordova, Node, browser, operating system):
Firefox 52 on Ubuntu 16.04 LTS, node 6.10.3

  1. Create a new angular project
  2. Create a component that injects a service that injects itself angularfire
  3. Try to open the component in a angular material dialog.

Debug output

* Errors in the JavaScript console *
ERROR Error: Uncaught (in promise): Error: No provider for InjectionToken FirebaseAppConfigToken!
injectionError@http://localhost:5555/node_modules/@angular/core/bundles/core.umd.js:1238:86 [angular]
noProviderError@http://localhost:5555/node_modules/@angular/core/bundles/core.umd.js:1276:12 [angular]
ReflectiveInjector_.prototype._throwOrNull@http://localhost:5555/node_modules/@angular/core/bundles/core.umd.js:2777:19 [angular]
ReflectiveInjector_.prototype._getByKeyDefault@http://localhost:5555/node_modules/@angular/core/bundles/core.umd.js:2816:20 [angular]
ReflectiveInjector_.prototype._getByKey@http://localhost:5555/node_modules/@angular/core/bundles/core.umd.js:2748:20 [angular]
ReflectiveInjector_.prototype.get@http://localhost:5555/node_modules/@angular/core/bundles/core.umd.js:2617:16 [angular]
get@ng:///AppModule/module.ngfactory.js:51:95 [angular]
get@ng:///AppModule/module.ngfactory.js:56:52 [angular]
get@ng:///AppModule/module.ngfactory.js:461:64 [angular]
anonymous/AppModuleInjector.p…
Stack trace:
[object Object]

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

* Screenshots *

Expected behavior

The component renders

Actual behavior

Error is thrown and angular app crashes

Most helpful comment

@AlvaroRM88 in the app.module.
then declare it like so imports: [AngularFireModule.initializeApp(firebaseConfig)]

All 20 comments

@ZuSe Can you create a plnkr reproducing this problem?

@davideast Should be possible. Is there any template for 4.0?

I spent some time this morning on the issue and figured out that everythings works when I don't use the umd bundle in my system.js config

BEFORE

        // ANGULARFIRE 2
        additionalPackages.push({
            name: 'angularfire2',
            path: `${this.NPM_BASE}angularfire2/bundles/angularfire2.umd.js`,
            packageMeta: {
              main: 'bundles/angularfire2.umd.js',
                defaultExtension: 'js'
            }

AFTER (WORKING):

     // ANGULARFIRE 2
        additionalPackages.push({
            name: 'angularfire2',
            path: `${this.NPM_BASE}angularfire2/angularfire2.js`,
            packageMeta: {
              main: 'angularfire2.js',
                defaultExtension: 'js'
            }
        });

Maybe it gives you already an idea what my cause it. There is defenitly some problem when generating the bundle (missing export etc.) .

This happened to me, it turned out I forgot to add the firebase config.

export const firebaseConfig = {
    apiKey: "",
    authDomain: "",
    databaseURL: "",
    projectId: "",
    storageBucket: ",
    messagingSenderId: ""
}

@sghaleb1 Where exactly you add firebase config? I have add the config in /src/environments/environment.ts, but I'm having the same problem of InjectionToken

@AlvaroRM88 in the app.module.
then declare it like so imports: [AngularFireModule.initializeApp(firebaseConfig)]

@sghaleb1 Thx for the answer, but I think my error is relationated with the version of angular cli and and firebase2.

I have the same problem when trying to add my firebase database as a provider instead of inside my app.module.ts.
the problem is I need 2 providers since I have 2 databases in the same projects and I can only put one single config in app.module.ts.

same problem here. injecting af-module in app-module. also tried all steps above. no success yet... any ideas? angular 4.1.3, firebase 4.1.2

Any solution?

I was able to solve it by updating angular core... I will post the working version number combinations later today.

Please post it because I have 4.2.5
I known that this is the last version

Thanks

Get Outlook for iOShttps://aka.ms/o0ukef


From: rahultyagiji notifications@github.com
Sent: Tuesday, July 4, 2017 10:51:09 PM
To: angular/angularfire2
Cc: MarinoRaul; Comment
Subject: Re: [angular/angularfire2] Error: No provider for InjectionToken FirebaseAppConfigToken! (#971)

I was able to solve it by updating angular core... I will post the working version number combinations later today.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/angular/angularfire2/issues/971#issuecomment-312977778, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AB5qSwyOf84pl0i6RD8UNSxAEwgXwMP1ks5sKuwNgaJpZM4NZFPP.

Is there any solution?

Is there any solution..Still i am struggling with this ..

Is the problem on running ng serve or ng test?

Same problem is happening to me when I am tryng to use firestore

in nativescript

I have no problem in Angular 4. Just in Nativescript

$ npm install firebase angularfire2 in angular 4. this should work fine. see this https://alligator.io/angular/cloud-firestore-angularfire/

TryAngularFireModule.initializeApp(environment.firebase), in app.module imports

I am having same problem... going crazy over this.. please help

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adriandurran picture adriandurran  Â·  3Comments

martinyoussef picture martinyoussef  Â·  3Comments

Maistho picture Maistho  Â·  3Comments

jnupeter picture jnupeter  Â·  3Comments

itisparas picture itisparas  Â·  3Comments