Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running into error: No template for dependency: ConstDependency #27

Closed
dominic-p opened this issue May 3, 2019 · 4 comments
Closed

Comments

@dominic-p
Copy link

I'm not 100% sure what's causing this, but I have a project with a dependency and that dependency loads a Worker. When I try to run webpack I get:

ERROR in chunk main [entry]
    main.js
    /path/to/project/node_modules/babel-loader/lib/index.js??ref--4!/path/to/project/node_modules/thrid-party-library/loadsWorker.jsx
    No template for dependency: ConstDependency

Maybe it has to do with the combination of babel and loading the Worker from a dependency of the main project. Any ideas?

@dominic-p
Copy link
Author

Ok, it looks like this problem came from using the wrong webpack. My main project actually relied on another dev dependency to run webpack. When, I use the locally installed version of webpack, this issue went away.

@wenganxiang
Copy link

wenganxiang commented Sep 30, 2019

I met the same problem, I used webpack installed in project. Could you please tell me more details about how to solve this problem?

@dominic-p
Copy link
Author

My setup is a little more complicated than most. Before this issue I had a main project that had a dev dependency on another project which in turn depended on webpack. I actually run webpack via gulp through the node API. So, before this, I was running a version of webpack that was not a direct dependency of the main project (and possibly a different version). My solution was to require the locally installed webpack and pass it to my dev dependency to use to run the build.

I assumed that the problem stemmed from using the dev dependency's version of webpack. But, if you are seeing this as well, maybe there's something else going on?

@SPKorhonen
Copy link

I had the same error when building Angular 9 app.

It seems that this error is caused by local install of package webpack under @angular-devkit when there is also an independent install under host package. I would guess that the code somehow uses files from node_modules@angular-devkit\build-angular\node_modules\webpack and node_modules\webpack somewhat haphazardly which leads to this error.

Namely the constructor object in the dependencyTemplates-map is generated form one and the dependency.constructor for the other. Thus they are not the same object and subsequently the constructor is not found from map leading to all kinds of fun and games...

It seems that ensuring identical versions of webpack in both locations and then running npm dedupe ensures that there is only one install of webpack and thus prevents this error.

I would recommend that you check if you have several webpack install in your node_modules and dedupe them as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants