Typescript error on ionic run android --aot

#1

[14:56:36] ionic-app-scripts 3.1.10
[14:56:36] build dev started …
[14:56:36] clean started …
[14:56:37] clean finished in 442 ms
[14:56:37] copy started …
[14:56:38] deeplinks started …
[14:56:39] deeplinks finished in 337 ms
[14:56:39] ngc started …
[14:57:12] typescript error
Type ParallaxHeaderDirective in C:/silentlabors/src/directives/parallax-header/parallax-header.ts is part of
the declarations of 2 modules: AppModule in C:/silentlabors/src/app/app.module.ts and DirectivesModule in
C:/silentlabors/src/directives/directives.module.ts! Please consider moving ParallaxHeaderDirective in
C:/silentlabors/src/directives/parallax-header/parallax-header.ts to a higher module that imports AppModule
in C:/silentlabors/src/app/app.module.ts and DirectivesModule in
C:/silentlabors/src/directives/directives.module.ts. You can also create a new NgModule that exports and
includes ParallaxHeaderDirective in C:/silentlabors/src/directives/parallax-header/parallax-header.ts then
import that NgModule in AppModule in C:/silentlabors/src/app/app.module.ts and DirectivesModule in
C:/silentlabors/src/directives/directives.module.ts.

[14:57:12] ionic-app-script task: “build”
[14:57:12] Error: The Angular AoT build failed. See the issues above
Error: The Angular AoT build failed. See the issues above
at C:\silentlabors\node_modules@ionic\app-scripts\dist\aot\aot-compiler.js:237:55
at step (C:\silentlabors\node_modules@ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
at Object.next (C:\silentlabors\node_modules@ionic\app-scripts\dist\aot\aot-compiler.js:13:53)
at fulfilled (C:\silentlabors\node_modules@ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
[ERROR] An error occurred while running subprocess ionic-app-scripts.

    ionic-app-scripts build --aot --target cordova --platform android exited with exit code 1.

ParallaxHeaderDirective seems to be the problem. But don’t have any idea how to fix it…

#2

Hello,

this is a often asked question. Read the message careful.
Depending on what you wanna do, comment one of the module in ngmodiule out.
For eager loading keep it in appmodule.ts and comment out the other one.
For lazy loading keep it in whatever.module.ts and comment it out in app.module.ts.

Best regards, anna-liebt

1 Like
#3

Can i have an example?? If you may?? :slightly_smiling_face:

#4

I solved it… thanks anna-liebt… :blush: