Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular -> No template for dependency: ConstDependency

Here is my code:

const worker = new Worker('./app.worker.ts', { type: 'module' });
console.log('this is the worker');
console.log(worker);
worker.onmessage = ({ data }) => {
  console.log(`page got message: ${data}`);
};
worker.postMessage('hello');

It is having trouble on that first line. If I remove the {type: 'module'} it does not give me the error (but it also does not work). I have tried npm prune and npm dedupe but that did not fix it.

like image 511
Ish Montalvo Avatar asked Oct 26 '25 00:10

Ish Montalvo


1 Answers

Removing webpack packages from package.json didn't resolve this for me.

Running npm i worker-plugin --save-dev resolved it for me. When running ng g web-worker the Angular CLI doesn't install the package.

like image 71
MDMoore313 Avatar answered Oct 28 '25 18:10

MDMoore313



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!