NativeScript: error NG8001: 'StackLayout' is not a known element
Environment I don’t think this is a NativeScript issue itself, but maybe someone got stacked with this and this could help.
"@nativescript/angular": "~10.1.0",
"@nativescript/core": "~7.0.0",
"@nativescript/theme": "~2.5.0",
"@nativescript/webpack": "~3.0.0",
Describe the bug
Unfortunately I was not able to find a pattern on how to reproduce, but it happened to me from time to time. I got these errors on several components when simply ns build android
:
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.
Yes, yes: I have put the NO_ERRORS_SCHEMA in the module. My project structure was one module and several components. Something like:
declarations: [
AppComponent,
HomeComponent,
LoginComponent,
FormComponent,
...
schemas: [NO_ERRORS_SCHEMA]
})
export class AppModule { }
and on components:
moduleId: module.id,
selector: 'app-form',
templateUrl: './form.component.html',
styleUrls: ['./form.component.css']
})
export class FormComponent implements OnInit {
To Reproduce Not really sure. I’ll continue working on steps. I’ve tried clean and build, but same thing.
Expected behavior Build
Solution I’ve created another temporal module and imported the complaining components into that new module and voilà! I haven’t removed them from the app module. After that I’ve commented the temporal module and everything was back working.
Looks like components got messed up with their parent modules.
Just Wondering
- How do I get files of the build process so I can have a deeper look into the issue?
- Am I correct doing one module+several components?
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 3
- Comments: 28
Hi, I had same error Fix: make sure all dot component.ts files in the app folder are referenced in app.module.ts, and checked app-routing.module.ts had all the necessary information
I got the error after migrate to NS7 from NS6.5 the error’s like this: error NG8001: ‘TextField’ is not a known element:
and the ‘NO_ERRORS_SCHEMA’ is already exist in module.tns.ts files in schemas: schemas: [NO_ERRORS_SCHEMA]
Sorry the delay, I’ve got distracted by latest video/song from AC/DC… apal.zip Here the sample project (actually the project I was working with).
@fabioalpizar My app has 2/3 components. They are all included in the app.module like this:
After the issue. I’ve created another module tempmod.module and imported it in the app.module. The tempmod is like this:
To workaround the issue, I remove the comment for the tempmod in the app.module just like this:
and it worked back. This worked for me. After I don’t-know-what, I was able to comment the tempmod from the app.module and everything worked back again.
Again, I was not able to find a pattern on how to reproduce.