1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Angular 19: NullInjectorError: No provider for _ResetGuard when navigating to...

Discussão em 'Angular' iniciado por jessiepinkman, Maio 23, 2025.

  1. I'm trying to debug a puzzling issue in our Angular 19 application that occurs during navigation to a recently added route /reset-confirm. The error we're getting is:

    NullInjectorError: R3InjectorError(AppModule)[_ResetGuard -> _ResetGuard -> _ResetGuard]:
    NullInjectorError: No provider for _ResetGuard!


    Here's a step-by-step account of what I've implemented, what works, what changed, and where it broke.

    Initial Setup and Working Components -


    • We have an authentication flow that includes SignInComponent, SignUpComponent, and VerifyComponent.


    • These components are wired up through Angular routing.


    • Access to /verify is protected using a VerifyGuard, which checks for sessionStorage entries and query parameters.


    • This entire flow works as expected and has passed QA.


    • These components are added to the AuthModule and are included in its imports array.

    New Components and Logic We introduced two new components:

    ForgotPasswordComponent – After a successful email send, it sets a sessionStorage key and navigates to /reset-confirmation using a custom RouterService.

    ResetConfirmationComponent – This component’s ngOnInit() checks for a sessionStorage value and query parameters to confirm access is valid. If not, it redirects the user to /login.

    The Problem

    When navigating to /reset-confirmation from ForgotPasswordComponent, we get the NullInjectorError

    Here’s what’s confusing:

    We do not have any guard named ResetGuard or _ResetGuard in the current codebase.

    We did have a ResetGuard previously but removed it — including removing it from all routes and providers.

    This error does not occur locally, only in staging builds.

    In app.config.ts, we define our routes using provideRouter(routes):

    export const appRoutes: Routes = [
    { path: 'login', component: SignInComponent },
    { path: 'sign-up', component: SignUpComponent },
    { path: 'verify', component: VerifyComponent, canActivate: [VerifyGuard] },
    ];


    All the components are standalone.

    I need serious help in this.

    Continue reading...

Compartilhe esta Página