ng-sticky icon indicating copy to clipboard operation
ng-sticky copied to clipboard

Error when building for production "ng build --prod"

Open dalvarezr opened this issue 7 years ago • 4 comments

ERROR in Error: Type NgStickyDirective in .../node_modules/ng-sticky/ng-sticky.d.ts is part of the declarations of 2 modules:

AppModule in .../src/app/app.module.ts

and

NgStickyModule in .../node_modules/ng-sticky/ng-sticky.d.ts!

Please consider moving NgStickyDirective in

.../node_modules/ng-sticky/ng-sticky.d.ts

to a higher module that imports AppModule in

.../src/app/app.module.ts and NgStickyModule

in

.../node_modules/ng-sticky/ng-sticky.d.ts.

You can also create a new NgModule that exports and includes NgStickyDirective in

.../node_modules/ng-sticky/ng-sticky.d.ts

then import that NgModule in AppModule in

.../src/app/app.module.ts and NgStickyModule

in

.../node_modules/ng-sticky/ng-sticky.d.ts

.

dalvarezr avatar Feb 07 '18 17:02 dalvarezr

A simple work around... just import the whole NgStickyModule into your apps appropriate module.

deanmono avatar Feb 26 '18 00:02 deanmono

Yes, moving NgStickyModule to imports[] works.

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        .....
        .....
        NgStickyModule,
    ],
    .....
})

Will this workaround impact performance or size?

mbn18 avatar Mar 14 '18 16:03 mbn18

@mbn18 did your solution resolved the issue, I've moved it to imports[] but it is still throwing the same error while ng build --prod

muneeb249 avatar Apr 17 '18 15:04 muneeb249

@muneeb249 , Yep. As seen above

Then in the template

<header ng-sticky [offSet]="0" [addClass]="'is-sticky'">

And scss

.narrow header, header.is-sticky {

mbn18 avatar Apr 17 '18 19:04 mbn18