angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Error: No provider for InjectionToken FirebaseAppConfigToken!

Open ZuSe opened this issue 9 years ago • 20 comments

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

ZuSe avatar May 12 '17 09:05 ZuSe

@ZuSe Can you create a plnkr reproducing this problem?

davideast avatar May 12 '17 12:05 davideast

@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.) .

ZuSe avatar May 13 '17 09:05 ZuSe

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

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

sghaleb1 avatar May 21 '17 17:05 sghaleb1

@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 avatar May 21 '17 17:05 AlvaroRM88

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

sghaleb1 avatar May 21 '17 18:05 sghaleb1

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

AlvaroRM88 avatar May 21 '17 19:05 AlvaroRM88

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.

thorizer avatar Jun 07 '17 13:06 thorizer

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

superstarmcawesome avatar Jun 07 '17 18:06 superstarmcawesome

Any solution?

MarinoRaul avatar Jul 04 '17 20:07 MarinoRaul

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

rahultyagiji avatar Jul 05 '17 01:07 rahultyagiji

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 [email protected] 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.

MarinoRaul avatar Jul 05 '17 09:07 MarinoRaul

Is there any solution?

FurkanArslan avatar Jul 15 '17 08:07 FurkanArslan

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

Thara45 avatar Sep 16 '17 07:09 Thara45

Is the problem on running ng serve or ng test?

kanomtang avatar Sep 22 '17 10:09 kanomtang

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

Denisijcu avatar Oct 10 '17 17:10 Denisijcu

in nativescript

Denisijcu avatar Oct 10 '17 17:10 Denisijcu

I have no problem in Angular 4. Just in Nativescript

Denisijcu avatar Oct 10 '17 17:10 Denisijcu

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

Denisijcu avatar Oct 10 '17 18:10 Denisijcu

Try AngularFireModule.initializeApp(environment.firebase), in app.module imports

DiegoVenancioVieira avatar Jan 20 '18 22:01 DiegoVenancioVieira

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

itscodezero avatar Apr 09 '18 11:04 itscodezero