Search code examples
angulartypescript

NullInjectorError: No provider for Kn


When accessing an Angular application page for the first time, the screen goes blank and shows this error : Error: Uncaught (in promise): NullInjectorError: R3InjectorError(e)[e -> e -> Kn]: NullInjectorError: No provider for Kn! NullInjectorError: NullInjectorError: No provider for Kn! but if you exit and return to it the content appears. as I have been working with Angular for a short time I am having difficulty identifying the cause

The only possible answer I found would be that Kn had not been imported and that it would be necessary to update the Angular version, but I didn't find anything related to Kn and even after updating Angular from version 16 to 17 the error continues I also didn't find anything related to Kn in the application or how to add


Solution

  • Kn is probably a minified / renamed variable. Try to get the error in uncompiled / uncompressed mode.

    R3InjectorError usually happens when you are trying to automatically inject (i.e., in a component constructor arguments) something that is not provided at root app level. For example, a service without providedIn: 'root'.