I have 2 projects written in Ionic with Angular 19 which are giving Nullinjector errors in production environment and not in development builds. In order to find out what would be causing these, I stripped one of my projects down to the bare minimum and I am still getting these Nullinjector errors. I’m not able to get more information about e.g. incorrect providers because the Nullinjector errors do not give more details in production. Example of the error:
NullInjectorError: R3InjectorError[t -> _i -> _i]:
NullInjectorError: No provider for _i!
The minimal app.config.ts
looks like this:
import { ApplicationConfig, importProvidersFrom } from '@angular/core';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { RouteReuseStrategy } from '@angular/router';
import { provideRouter, withPreloading, PreloadAllModules } from '@angular/router';
import { routes } from './app-routing.module';
import { provideAuth, getAuth, indexedDBLocalPersistence, browserLocalPersistence } from '@angular/fire/auth';
import { isPlatform } from '@ionic/angular';
export const appConfig: ApplicationConfig = {
providers: [
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
provideAuth(() => {
const auth = getAuth();
if (isPlatform('android')) {
auth.setPersistence(indexedDBLocalPersistence);
} else {
auth.setPersistence(browserLocalPersistence);
}
return auth;
}),
provideRouter(routes, withPreloading(PreloadAllModules)),
importProvidersFrom(IonicModule.forRoot())
]
};
What could be missing here?