flex-layout icon indicating copy to clipboard operation
flex-layout copied to clipboard

StaticInjectorError(AppModule)[FlexDirective -> MediaMonitor] on serve --aot

Open tanou73 opened this issue 8 years ago • 5 comments

Bug

I created a component library that use FlexLayout. I package this library using ng-packagr, and then include it in other projects in order to easily reuse components.

When I run "ng serve --aot" in the application that use my library, I have the following error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[FlexDirective -> MediaMonitor]

What is the expected behavior?

No errors :)

What is the current behavior?

No problem with "ng serve", but if I run "ng serve --aot", and use a component of my library that use FlexLayout, I have the following stacktrace:

ERROR Error: StaticInjectorError(AppModule)[FlexDirective -> MediaMonitor]: StaticInjectorError(Platform: core)[FlexDirective -> MediaMonitor]: NullInjectorError: No provider for MediaMonitor! at NullInjector.get (core.js:1002) at resolveToken (core.js:1300) at tryResolveToken (core.js:1242) at StaticInjector.get (core.js:1110) at resolveToken (core.js:1300) at tryResolveToken (core.js:1242) at StaticInjector.get (core.js:1110) at resolveNgModuleDep (core.js:10850) at NgModuleRef.get (core.js:12083) at resolveDep (core.js:12573)

What are the steps to reproduce?

Hard to reproduce. You have to create a project with a component that use FlexLayout, then build it with ng-packagr and use it in another app.

What is the use-case or motivation for changing an existing behavior?

Obvious :)

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Windows 10, Chrome latest "@angular/cdk": "^5.2.1", "@angular/material": "^5.2.1", "typescript": "~2.5.3"

Is there anything else we should know?

I have try to dig this issue as mush as I could, but I admit I'm a bit lost :)

tanou73 avatar Feb 16 '18 10:02 tanou73

same issue here @tanou73 how did you solve it? I downgraded to v2.0.0-beta12 that seems to work fine

JanEggers avatar May 15 '18 11:05 JanEggers

I solved it for some time now, but I think that I ended up adding flex-layout as externals in the ng-packager.json and list it in the peer-dependencies

tanou73 avatar May 15 '18 15:05 tanou73

@tanou73 Can you provide a link to a minimal reproduction?

CaerusKaru avatar Jun 11 '18 03:06 CaerusKaru

Since it’s been a few months and no demo has been provided, I’m closing this issue. If a demo is provided we can reopen it.

CaerusKaru avatar Nov 04 '18 20:11 CaerusKaru

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.