angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.64k stars 2.2k forks source link

Error uploading image: Error: Either AngularFireModule has not been provided in your AppModule ( project v17 standalone) #3552

Open thanhnguyen568 opened 1 week ago

thanhnguyen568 commented 1 week ago

Version info

Angular: 17.3.0

Firebase: 10.12.2

AngularFire: 17.1.0

Debug output

Errors in the JavaScript console: Error uploading image: Error: Either AngularFireModule has not been provided in your AppModule (this can be done manually or implictly using provideFirebaseApp) or you're calling an AngularFire method outside of an NgModule (which is not supported). at getSchedulers (angular-fire.mjs:142:11) at runOutsideAngular (angular-fire.mjs:148:10) at angular-fire.mjs:216:17 at _UploadService. (upload.service.ts:15:23) at Generator.next () at main.js:18:61 at new ZoneAwarePromise (zone.js:2611:25) at __async (main.js:2:10) at _UploadService.uploadFile (upload.service.ts:12:30) at _DialogExaminationFormUpdateComponent. (dialog-examination-form-update.component.ts:125:54)

Screenshots image

google-oss-bot commented 1 week ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

BurscherChris commented 1 week ago

It could be that you are using getAuth(), getStorage(), or getFireStore() within a service or component.

I encountered a similar issue when I was using getAuth() directly in my service like this:

const auth = getAuth();
const uc = await signInWithEmailAndPassword(auth, email, password);

After modifying my approach to the following, my code started working correctly:

constructor(private _auth: AngularFireAuth) {}

...

const uc = await this._auth.signInWithEmailAndPassword(email, password);

I hope this helps!

KingDarBoja commented 1 week ago

Just in case, try to remove node_modules and yarn.lock or package-lock.json and do a fresh install as sometimes there are multiple firebase versions being called without noticing.