"The AppComponent class is a standalone component, which can not be used in the...

Discussão em 'Angular' iniciado por Alex161, Janeiro 13, 2025.

  1. Alex161

    Alex161 Guest

    my Nativescript-Angular project was full workable two month ago, but now unexpectedly shutdown, I even don't know what exactly changing made in my environment, Angular look as the same version

    Angular CLI: 18.1.3
    Node: 22.6.0
    Package Manager: npm 10.8.2
    OS: win32 x64
    Angular: 18.1.3
    ... animations, cli, common, compiler, compiler-cli, core, forms
    ... platform-browser, platform-browser-dynamic, router
    Package Version
    ---------------------------------------------------------
    @angular-devkit/architect 0.1800.7
    @angular-devkit/build-angular 18.1.3
    @angular-devkit/core 18.1.3
    @angular-devkit/schematics 18.1.3
    @ngtools/webpack 18.1.3
    @schematics/angular 18.1.3
    rxjs 7.8.1
    typescript 5.5.4
    zone.js 0.14.8


    Nativescript is the same version

    ns --version
    8.8.0


    But unexpectedly I receive this error message:

    "The AppComponent class is a standalone component, which can not be used in the @NgModule.bootstrap array. Use the bootstrapApplication function for bootstrap instead.(-996009) app.module.ts(23, 1): The 'bootstrap' array is present on this NgModule." and project stop compiling.

    this was my old app.module.ts

    ...
    registerElement('NativeAdView', () => require('@nativescript/firebase-admob').NativeAdView);
    registerElement('BannerAd', () => require('@nativescript/firebase-admob').BannerAd);
    registerElement('MediaView', () => require('@nativescript/firebase-admob').MediaView);

    @NgModule({
    bootstrap: [AppComponent],
    imports: [NativeScriptModule, AppRoutingModule, InstallModule, NativeScriptFormsModule, FormsModule, ReactiveFormsModule,CheckBoxModule ],
    declarations: [AppComponent, ListComponent, ItemDetailComponent, ...demoCOMPONENTS, WelcomeComponent,AddNewComponent,SecurityComponent,MoreComponent ],
    providers: [],
    schemas: [NO_ERRORS_SCHEMA],
    })
    export class AppModule {}


    I try to change project to Angular standalone components, add to each declaration

    @Component({
    standalone: true,


    and change app.module.ts:

    ...
    registerElement('NativeAdView', () => require('@nativescript/firebase-admob').NativeAdView);
    registerElement('BannerAd', () => require('@nativescript/firebase-admob').BannerAd);
    registerElement('MediaView', () => require('@nativescript/firebase-admob').MediaView);

    @NgModule({
    imports: [NativeScriptModule, AppRoutingModule, InstallModule, NativeScriptFormsModule, FormsModule, ReactiveFormsModule,CheckBoxModule ],
    providers: [
    importProvidersFrom(NativeScriptRouterModule.forRoot([])),
    ],
    schemas: [NO_ERRORS_SCHEMA],
    })
    export class AppModule {}


    But have no positive result, I receive just million lines of error during compiling process, no more. Now project looks as fully destroyed and I even don't know what tiny changing in my developer environment destroyed cool workable project.
    Any ideas please.

    Continue reading...

Compartilhe esta Página