4

I'm facing a weird issue when I build my NS app in AOT. I'm running the command tns build android --bundle --release --env.aot <other_key_specific_flags> I'm getting below error.

: 'StackLayout' is not a known element:
1. If 'StackLayout' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
    </FlexboxLayout>
  </StackLayout>
  [ERROR ->]<StackLayout *ngIf="dataEmpty" class="m-25">
    <Label class="fo-24 text-center" text="No Activitie")
: 'StackLayout' is not a known element:
1. If 'StackLayout' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("[ERROR ->]<StackLayout class="a-m-t-25">
  <FlexboxLayout class="app-action-bar" margin="10 5 5 10" justifyCon")


ERROR in ./app/content/profile/profile.component.ts 109:32
Module parse failed: Unexpected token (109:32)
You may need an appropriate loader to handle this file type.
|         core_1.Component({
|             selector: 'ns-profile',
>             /*duleId: module.i*/+ ' ',
|             templateUrl: './profile.component.html',
|             styleUrls: ['./profile.component.scss']
 @ ./app/app.module.ts 33:26-72
 @ ./main.ts

My app.module.ts though contains NO_ERRORS_SCHEMA

...
import { CommonModule } from '@angular/common';
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
...

@NgModule({
  schemas: [
    NO_ERRORS_SCHEMA
  ],
  bootstrap: [
    AppComponent
  ],
  imports: [
    CommonModule,
    NativeScriptModule,
    ...
  ],
  declarations: [...],
  providers: [...]
})
export class AppModule {
}
Yashwardhan Pauranik
  • 5,370
  • 5
  • 42
  • 65

1 Answers1

0

Same thing happened here. I've solved it by creating a Module with the same name as the Component and adding that NgModule NO_ERRORS_SCHEMA.

Something like:

      @NgModule({
     schemas: [
       NO_ERRORS_SCHEMA
     ],
     bootstrap: [
       AppComponent
     ],
     imports: [
       CommonModule,
       NativeScriptModule,
       ...
     ],
     declarations: [...],
     providers: [...]
   })
   export class ProfileModule {
   }

and then import that into the app.module.

Pablo Gutierrez
  • 112
  • 1
  • 4