Skip to content

Unclear resolution for "The component must be standalone" #48945

@eternalmatt

Description

@eternalmatt

Describe the problem that you experienced

This error is printed in the console and can be more clear.

See the assertStandalone function:
https://github.com/angular/angular/blob/main/packages/router/src/utils/config.ts

The error told me to "Invalid configuration of route 'XYZ' The component must be standalone"

However, this would NOT fix my problem. The issue was not that my component MUST be standalone. Rather, I was using it in a non-standalone situation.

Enter the URL of the topic with the problem

https://github.com/angular/angular/blob/main/packages/router/src/utils/config.ts

Describe what you were looking for in the documentation

Describe in more detail 'standalone'. Perhaps say "This component is trying to be loaded as standalone but it is not marked as standalone. Did you mean to include it in a module?"

Describe the actions that led you to experience the problem

My issue is that I incorrectly used loadComponent instead of loadChildren which is an obvious mistake. However I likely did this because the two properties are named similar and did not present any type-safety problems.

Describe what you want to experience that would fix the problem

Better error messaging. Type Safety would be best.

Add a screenshot if that helps illustrate the problem

No response

If this problem caused an exception or error, please paste it here

{
    path: 'protected',
    canLoad: [OktaAuthGuard],
    canActivate: [OktaAuthGuard],
    loadComponent: () => import('./protected/protected.module').then((m) => m.ProtectedModule),
  },


### If the problem is browser-specific, please specify the device, OS, browser, and version

_No response_

### Provide any additional information here in as much as detail as you can

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: routerhelp wantedAn issue that is suitable for a community contributor (based on its complexity/scope).hotlist: error messagesrouter: lazy loading

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions