question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No module factory available for dependency type: ContextElementDependency

See original GitHub issue

Do you want to request a feature or report a bug?

Possibly a bug - seeking advice on how to track down the error. It seems to be an imcompatibility between 3.10.0 and 3.11.0 that I’d like to understand so I can solve similiar problems in the future.

What is the current behavior?

An angular 6.0.0-beta.4 app compiles fine on Webpack 3.10.0 but fails with the error mentioned in the title when upgrading to 3.11.0 It fails for my two lazy-loaded modules although I’m using @ngtools/webpack, even adding angular-router-loader doesn’t solve the problem (and shouldn’t be required as it works without in 3.10.0)

If the current behavior is a bug, please provide the steps to reproduce.

Can’t offer a repro as the project is closed source.

What is the expected behavior?

The app compiles.

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.

node 9.3.0 webpack 3.11.0 webpack-dev-middleware 2.0.5 ngtools/webpack 1.10.0-rc.0 angular 6.0.0-beta.4

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
actra-gschustercommented, Feb 15, 2018

OK, I understand, there’s no chance (and need) to try to debug other than bugging library authors to regularly update their dependencies. For the time being I’ll solve it by specifing resolutions in my package.json.

Thanks for your support!

1reaction
filipesilvacommented, Feb 15, 2018

IIRC it is not that the the second version is pulled into the firsts compilation, but rather that different webpack plugins are using different versions of stuff like ContextElementDependency.

In this specific case, @ngtools/webpack imports ContextElementDependency

https://github.com/angular/angular-cli/blob/9a593dd32cb79ec6f581c7bd2d5ca1d4cbdddcdd/packages/%40ngtools/webpack/src/angular_compiler_plugin.ts#L7

in order to correctly populate the context dependencies for the angular/core import() call

https://github.com/angular/angular-cli/blob/9a593dd32cb79ec6f581c7bd2d5ca1d4cbdddcdd/packages/%40ngtools/webpack/src/angular_compiler_plugin.ts#L587-L596

Depending on your node_modules structure, the plugin might be using ContextElementDependency from a different Webpack than the one that is running.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular No module factory available for dependency type
Steps I took to fix this problem in case if someone encounters it: Package.json: remove webpack from DevDependencies; rm -R node_modules ...
Read more >
"No module factory available for dependency type ... - GitHub
"No module factory available for dependency type: ContextElementDependency" after migrating an universal project to Angular 7 #13298.
Read more >
No module factory available for dependency type - Medium
“”No module factory available for dependency type: ContextElementDependency” after migrating an universal project to Angular 7".
Read more >
if a add a module with routing module, ng serve will fail
these are errors: assets/scss/bootstrap/bootstrap.scss ✖ 「wdm」: Error: No module factory available for dependency type: ContextElementDependency ...
Read more >
angular/angular-cli - Gitter
When I run my app locally, I use a proxy to send api requests to a different port on my computer. But if...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found