Nativescript-angular: Webpack build command for android creates <component> is not a known element error

Created on 24 Nov 2017  路  2Comments  路  Source: NativeScript/nativescript-angular

I have a Nativescript angular project. After it became ready for publishing I installed webpack for nativescript. When I run npm run build-android-bundle it gives me component is not a known element error:

````
ERROR in Template parse errors:
'image' is not a known element:

  1. If 'image' 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. ("exboxLayout flexDirection="column" justifyContent="center">

    [ERROR ->]
    <Tex"): ng:///home/zarax/code/cubicl-mobile/app/pages/login/login.html@2:2

'FlexboxLayout' is not a known element:

  1. If 'FlexboxLayout' 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 ->]

    "): ng:///home/zarax/code/cubicl-mobile/app/pages/login/login.html@0:0

ERROR in ./main.aot.ts
Module not found: Error: Can't resolve './app/app.module.ngfactory' in '/home/zarax/code/cubicl-mobile/app'
@ ./main.aot.ts 5:29-66
````
I searched the internet but couldn't find a solution.

My tns-android version is 3.2.0. ngtools/webpack version is 1.6.0.

Thanks

Most helpful comment

I found the solution. You have to put NO_ERRORS_SCHEMA to all custom NgModule declarations:

ts import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';

ts @NgModule({ // ... schemas: [ NO_ERRORS_SCHEMA ] })

This is not needed for building project without webpack and not mentioned on nativescript webpack documentation. This should be added to documentation to prevent confusion.

All 2 comments

I found the solution. You have to put NO_ERRORS_SCHEMA to all custom NgModule declarations:

ts import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';

ts @NgModule({ // ... schemas: [ NO_ERRORS_SCHEMA ] })

This is not needed for building project without webpack and not mentioned on nativescript webpack documentation. This should be added to documentation to prevent confusion.

I found the solution. You have to put NO_ERRORS_SCHEMA to all custom NgModule declarations:

import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
@NgModule({
    // ...
    schemas: [
        NO_ERRORS_SCHEMA
    ]
})

This is not needed for building project without webpack and not mentioned on nativescript webpack documentation. This should be added to documentation to prevent confusion.

Works for me!

Was this page helpful?
0 / 5 - 0 ratings