RuntimeError: NG0203: The `EnvironmentInjector` token injection failed. Migrating Angular 18...

Discussão em 'Angular' iniciado por Geometry, Março 19, 2025.

  1. Geometry

    Geometry Guest

    I updated Angular from 18 to 19 with ng update @angular/core@19 @angular/cli@19, and manually updated "@angular/core": "^18.0.5" to "@angular/fire": "19.0.0".


    @NgModule({
    imports: [
    ...
    AngularFireModule.initializeApp(firebaseConfig),
    AngularFirestoreModule,
    ...
    ]



    @Injectable({
    providedIn: 'root',
    })
    export class RepositoryService {
    constructor(private angularFirestore: AngularFirestore) { }
    ...


    I expect to boot an app, but having this error

    ERROR RuntimeError: NG0203: The `EnvironmentInjector` token injection failed. `inject()` function must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`. Find more at https://angular.dev/errors/NG0203

    Continue reading...

Compartilhe esta Página