"Error: Cannot find module '/engine-learn/Worker'" or "Error: expose() called in the master thread."
- Linguagem predominante
- TypeScript
- Estrelas
- 3.5k
- Forks
- 173
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
My Nx setup using `threads.js` ain't working...I'm getting either this error:
> Error: Cannot find module 'engine-learn/Worker'
...when my setup looks like this:
```
// index.ts
export * from './EngineLearn';
// Worker.ts
import { expose } from 'threads/worker';
const trainModel = async () => {
console.log("In trainModel");
};
expose(trainModel);
// EngineLearn.ts
import { Pool, spawn, Worker } from 'threads';
export class EngineLearn {
trainModels = async () => {
console.log('Hello');
const pool = Pool(() => spawn(new Worker('./Worker')));
};
}
```
...or, if I export `Worker.ts` in my root `index.ts`, like this:
```
// index.ts
export * from './EngineLearn';
export * from './Worker';
```
...I get:
> "Error: expose() called in the master thread."
It seems the module is not included in the build if I export it in `index.ts`, and so cannot be found; but, if I do, `expose()` is immediately invokes and it gives rise to the other error.
What to do 🤷🏻
I am using the `@nrwl/esbuild:esbuild` build executor.
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Avaliação
Esta issue ainda não foi avaliada.