Skip to content

"No Firebase App '[DEFAULT]' has been created" when using " provideFirebaseApp(() => initializeApp(environment.firebase))," in app.module.ts imports array, getStorage() #3443

@TheRealSamChaney

Description

@TheRealSamChaney

Version info

Angular:
^16.2.0

Firebase:
^10.4.0

AngularFire:
^7.6.1

Other (e.g. Ionic/Cordova, Node, browser, operating system):

How to reproduce these conditions

Steps to set up and reproduce
Create Angular app via ng new appName, add Angularfire with ng add @angular/fire, initialize Firebase app in app.module.ts using the following in the imports array:

provideFirebaseApp(() => initializeApp(environment.firebase)),
Then, integrate firebase app via environments (create with ng add environment if needed), add storage service that connects to storage bucket via getStorage()

Debug output

ERROR Error: Uncaught (in promise): FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call initializeApp() first (app/no-app).
FirebaseError@http://localhost:4200/vendor.js:73648:5
create@http://localhost:4200/vendor.js:73676:19
getApp@http://localhost:4200/vendor.js:154432:25
getStorage@http://localhost:4200/vendor.js:72546:80
4886/ɵzoneWrap/</ret<@http://localhost:4200/vendor.js:1279:44
4886/runOutsideAngular/<@http://localhost:4200/vendor.js:1211:57
invoke@http://localhost:4200/polyfills.js:8209:158
run@http://localhost:4200/polyfills.js:7994:35
runOutsideAngular@http://localhost:4200/vendor.js:108406:24
runOutsideAngular@http://localhost:4200/vendor.js:1211:33
4886/ɵzoneWrap/<@http://localhost:4200/vendor.js:1279:34
StorageService@http://localhost:4200/main.js:914:85
StorageService_Factory@http://localhost:4200/main.js:918:12
1699/hydrate/<@http://localhost:4200/vendor.js:106890:33
runInInjectorProfilerContext@http://localhost:4200/vendor.js:98413:5
hydrate@http://localhost:4200/vendor.js:106889:37
get@http://localhost:4200/vendor.js:106769:23
get@http://localhost:4200/vendor.js:111362:32
lookupTokenUsingModuleInjector@http://localhost:4200/vendor.js:102129:31
getOrCreateInjectable@http://localhost:4200/vendor.js:102175:10
ɵɵdirectiveInject@http://localhost:4200/vendor.js:109230:38
ProductsComponent_Factory@http://localhost:4200/main.js:640:211
getNodeInjectable@http://localhost:4200/vendor.js:102369:38
createRootComponent@http://localhost:4200/vendor.js:111603:48
create@http://localhost:4200/vendor.js:111470:19
createComponent@http://localhost:4200/vendor.js:121503:43
activateWith@http://localhost:4200/vendor.js:145921:31
activateRoutes@http://localhost:4200/vendor.js:146519:28
7947/activateChildRoutes/<@http://localhost:4200/vendor.js:146473:12
activateChildRoutes@http://localhost:4200/vendor.js:146472:25
activate@http://localhost:4200/vendor.js:146383:10
7947/activateRoutes/<@http://localhost:4200/vendor.js:146367:120
9736/map/</<@http://localhost:4200/vendor.js:82387:31
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
3738/tap/</<@http://localhost:4200/vendor.js:83039:18
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
9736/map/</<@http://localhost:4200/vendor.js:82387:18
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
1891/switchMap/</</innerSubscriber<@http://localhost:4200/vendor.js:82897:243
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
9736/map/</<@http://localhost:4200/vendor.js:82387:18
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
384/fromArrayLike/<@http://localhost:4200/vendor.js:81823:18
_trySubscribe@http://localhost:4200/vendor.js:80744:19
2235/subscribe/<@http://localhost:4200/vendor.js:80738:113
errorContext@http://localhost:4200/vendor.js:83975:5
subscribe@http://localhost:4200/vendor.js:80733:69
9736/map/<@http://localhost:4200/vendor.js:82386:12
4114/operate/</<@http://localhost:4200/vendor.js:84264:18
2235/subscribe/<@http://localhost:4200/vendor.js:80738:42
errorContext@http://localhost:4200/vendor.js:83975:5
subscribe@http://localhost:4200/vendor.js:80733:69
1891/switchMap/</<@http://localhost:4200/vendor.js:82897:100
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
1891/switchMap/</</innerSubscriber<@http://localhost:4200/vendor.js:82897:243
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
9736/map/</<@http://localhost:4200/vendor.js:82387:18
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
1527/take/</<@http://localhost:4200/vendor.js:82932:20
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
728/defaultIfEmpty/</<@http://localhost:4200/vendor.js:82177:20
5678/OperatorSubscriber/this._complete<@http://localhost:4200/vendor.js:82050:9
complete@http://localhost:4200/vendor.js:81135:12
384/fromArrayLike/<@http://localhost:4200/vendor.js:81825:16
_trySubscribe@http://localhost:4200/vendor.js:80744:19
2235/subscribe/<@http://localhost:4200/vendor.js:80738:113
errorContext@http://localhost:4200/vendor.js:83975:5
subscribe@http://localhost:4200/vendor.js:80733:69
728/defaultIfEmpty/<@http://localhost:4200/vendor.js:82172:12
4114/operate/</<@http://localhost:4200/vendor.js:84264:18
2235/subscribe/<@http://localhost:4200/vendor.js:80738:42
errorContext@http://localhost:4200/vendor.js:83975:5
subscribe@http://localhost:4200/vendor.js:80733:69
1527/take/<@http://localhost:4200/vendor.js:82930:12
4114/operate/</<@http://localhost:4200/vendor.js:84264:18
2235/subscribe/<@http://localhost:4200/vendor.js:80738:42
errorContext@http://localhost:4200/vendor.js:83975:5
subscribe@http://localhost:4200/vendor.js:80733:69
9736/map/<@http://localhost:4200/vendor.js:82386:12
4114/operate/</<@http://localhost:4200/vendor.js:84264:18
2235/subscribe/<@http://localhost:4200/vendor.js:80738:42
errorContext@http://localhost:4200/vendor.js:83975:5
subscribe@http://localhost:4200/vendor.js:80733:69
1891/switchMap/</<@http://localhost:4200/vendor.js:82897:100
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
1891/switchMap/</</innerSubscriber<@http://localhost:4200/vendor.js:82897:243
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
9736/map/</<@http://localhost:4200/vendor.js:82387:18
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
3738/tap/</<@http://localhost:4200/vendor.js:83039:18
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
1891/switchMap/</</innerSubscriber<@http://localhost:4200/vendor.js:82897:243
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
3738/tap/</<@http://localhost:4200/vendor.js:83039:18
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
8164/mergeInternals/doInnerSub/<@http://localhost:4200/vendor.js:82471:20
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
8164/mergeInternals/doInnerSub/<@http://localhost:4200/vendor.js:82471:20
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
384/fromArrayLike/<@http://localhost:4200/vendor.js:81823:18
_trySubscribe@http://localhost:4200/vendor.js:80744:19
2235/subscribe/<@http://localhost:4200/vendor.js:80738:113
errorContext@http://localhost:4200/vendor.js:83975:5
subscribe@http://localhost:4200/vendor.js:80733:69
doInnerSub@http://localhost:4200/vendor.js:82466:95
outerNext@http://localhost:4200/vendor.js:82461:52
5678/OperatorSubscriber/this._next<@http://localhost:4200/vendor.js:82034:15
next@http://localhost:4200/vendor.js:81119:12
7344/takeLast/</<@http://localhost:4200/vendor.js:82968:20
5678/OperatorSubscriber/this._complete<@http://localhost:4200/vendor.js:82050:9

Expected behavior

Storage service should work fine. It should not be possible for any component or module to access the firebase app before its created when its initialized in the app.module.ts imports array.

Actual behavior

Storage service causes Firebase error "ERROR Error: Uncaught (in promise): FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call initializeApp() first (app/no-app)."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions