Comments (12)
Oh fun, that shouldn't have broken... sorry probably should have saved that one for v18.
You can pull the "provideFirebase" functions outside of the importProvidersFrom
call and you'll be back up and running again.
from angularfire.
I'm sorry I didn't understand this - if I pull all the @angular/fire providers outside the importProvidersFrom function, and add them to the providers array directly, the error stays the same (on v18, both NG and Fire).. any help? Here is my firebase config:
import { importProvidersFrom, EnvironmentProviders, Injector } from '@angular/core'; import { provideFirebaseApp, initializeApp, getApp } from '@angular/fire/app'; import { getFirestore, provideFirestore } from '@angular/fire/firestore'; import { provideAuth, initializeAuth, browserPopupRedirectResolver } from '@angular/fire/auth'; import { environment } from '@environment'; import { browserLocalPersistence, browserSessionPersistence } from '@firebase/auth'; const firebaseProviders: EnvironmentProviders = importProvidersFrom([ provideFirebaseApp(() => initializeApp(environment.firebase)), provideFirestore(() => getFirestore()), provideAuth(() => initializeAuth(getApp(), { persistence: [browserSessionPersistence, browserLocalPersistence], popupRedirectResolver: browserPopupRedirectResolver }) ) ]); export { firebaseProviders };
simple example for app.config.ts (Angular 18).
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(appRoutes),
provideFirebaseApp(() => initializeApp(firebaseConfig)),
provideFirestore(() => getFirestore()),
],
};
As you can see, both provideFirebaseApp as well as provideFirestore are not inside the importProvidersFrom function, like required before and you are using in your example above, that was meant with "pull outside importProvidersFrom". Does this help?
from angularfire.
@schreibse thanks, that is what I tried but got the same issue.. I'll give it another shot.. thank you so much
Is it also provideAuth that should be pulled out?
from angularfire.
It was working fine with angular < 18, I just upgraded to angular 18 and facing this error:
[ERROR] TS2345: Argument of type 'EnvironmentProviders' is not assignable to parameter of type 'ImportProvidersSource'. [plugin angular-compiler]
[ng]
[ng] src/main.ts:63:47:
[ng] 63 │ ...orRoot(), provideFirebaseApp(() => initializeApp(environment.fi...
from angularfire.
Hey guys, I managed now by pulling the calls out, as suggested. Previously I got errros when doing so but it works now, thank you all for good suggestions.
Edit: I see now that the error I had was fixed with the newly added version 18.0.1 #3536
from angularfire.
@schreibse it seems to be working with @angular/fire 18.0.1
from angularfire.
This issue does not seem to follow the issue template. Make sure you provide all the required information.
from angularfire.
Thank you for the fast reply, that worked!
from angularfire.
I'm sorry I didn't understand this - if I pull all the @angular/fire providers outside the importProvidersFrom function, and add them to the providers array directly, the error stays the same (on v18, both NG and Fire).. any help? Here is my firebase config:
import { importProvidersFrom, EnvironmentProviders, Injector } from '@angular/core';
import { provideFirebaseApp, initializeApp, getApp } from '@angular/fire/app';
import { getFirestore, provideFirestore } from '@angular/fire/firestore';
import { provideAuth, initializeAuth, browserPopupRedirectResolver } from '@angular/fire/auth';
import { environment } from '@environment';
import { browserLocalPersistence, browserSessionPersistence } from '@firebase/auth';
const firebaseProviders: EnvironmentProviders = importProvidersFrom([
provideFirebaseApp(() => initializeApp(environment.firebase)),
provideFirestore(() => getFirestore()),
provideAuth(() =>
initializeAuth(getApp(), {
persistence: [browserSessionPersistence, browserLocalPersistence],
popupRedirectResolver: browserPopupRedirectResolver
})
)
]);
export { firebaseProviders };
from angularfire.
@schreibse thanks, that is what I tried but got the same issue.. I'll give it another shot.. thank you so much Is it also provideAuth that should be pulled out?
yes, everything related to firebase has to be pulled out of importProvidersFrom
.
It might help to read the steps/code of the AngularFire web codelab
from angularfire.
@schreibse I am on ng18 btw
from angularfire.
It was working fine with angular < 18, I just upgraded to angular 18 and facing this error:
[ERROR] TS2345: Argument of type 'EnvironmentProviders' is not assignable to parameter of type 'ImportProvidersSource'. [plugin angular-compiler] [ng] [ng] src/main.ts:63:47: [ng] 63 │ ...orRoot(), provideFirebaseApp(() => initializeApp(environment.fi...
yes, hence this issue. Did you try the proposed solution It works fine after extracting everything firebase related from importProvidersFrom(...)
@schreibse I am on ng18 btw
Me as well! I created a new angular workspace with cli and configured firebase.
From package.json:
"@angular/animations": "^18.0.0",
"@angular/common": "^18.0.0",
"@angular/compiler": "^18.0.0",
"@angular/core": "^18.0.0",
"@angular/fire": "^18.0.1",
"@angular/forms": "^18.0.0",
"@angular/platform-browser": "^18.0.0",
"@angular/platform-browser-dynamic": "^18.0.0",
"@angular/router": "^18.0.0",
After I encountered the error I found this issue with the working solution. Please share your app.config.ts
as well as separate provider files (from your code snippet above it seems like you have one for firebase)
from angularfire.
Related Issues (20)
- Either AngularFireModule has not been provided in your AppModule HOT 1
- [Angular 15 + Firebase 7] Build in production mode error: Component auth has not been registered yet HOT 1
- Unable to load dynamic firebase config, tried many ways but fail to load. HOT 2
- fireMessaging.tokenChanges emit wrong(not equeal) fcm token after fireMessaging.requestToken HOT 1
- vertexai-preview Module '"@firebase/app"' has no exported member '_FirebaseService' HOT 2
- GoogleAuthProvider not exported anymore in v18 HOT 10
- AngularFire v18 ng serve error when using zoneless change detection: Zone is not defined HOT 4
- Missing exports in v18? HOT 2
- AngularFireAuthGurd is missing
- Unable to use order by desc HOT 6
- The convience observables provided by the Auth module are no longer type safe HOT 3
- [Feature Request] authCanMatchGuard + helpers HOT 1
- Implementing Firebase App Check Debug Token in an Angular Application HOT 1
- `ng deploy` infinite setup loop
- GRPC-JS vulnerability,
- Two consecutive `subscribe` calls on the Observable created by `authState()` cause Angular app to never become stable.
- ng-deploy's browserTarget and prerender's browserTarget do not match. Please check your angular.json HOT 1
- setPersistence in AngularFire _BrowserLocalPersistence cannot be invoked without 'new'` HOT 1
- Timeout just in the first load with Angular 18 and SSR
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angularfire.