Angular 19: 'imports' is only valid on a component that is standalone

Discussão em 'Angular' iniciado por Prashant sharma, Dezembro 4, 2024.

  1. I am migrating my angular library from v18 to v19.

    Before upgrade components looked like following:


    @Component({
    selector: "custom-component",
    templateUrl: "./custom.component.html",
    styleUrls: ["./custom.component.scss"],
    standalone: true,
    imports: [
    MatIconModule,
    CommonModule,
    ... other imports
    ],


    Since after upgrade standalone: true is removed in migration process referred here in official Angular Docs.

    Now after upgrade I am getting error:

    'imports' is only valid on a component that is standalone.(-992010)

    my component after automatic upgrade looks like this:


    @Component({
    selector: "custom-component",
    templateUrl: "./custom.component.html",
    styleUrls: ["./custom.component.scss"],
    imports: [
    MatIconModule,
    CommonModule,
    ... other imports
    ],


    Any help is appreciated.

    I have updated angular-language-service and also restarted vs-code but nothing helped.

    Continue reading...

Compartilhe esta Página