threads.js icon indicating copy to clipboard operation
threads.js copied to clipboard

Worker Path Module not found

Open anwarjaved opened this issue 2 years ago • 1 comments

I am trying to load Worker from same directory in nodejs typescript it always throws Error: Cannot find module I tried to load using relative path and also by absolute path but it always failed

anwarjaved avatar Feb 11 '23 07:02 anwarjaved

Was literally about to post the same message...I have this:

import { Pool, spawn, Worker } from 'threads';
import * as w from './Worker';

export class EngineLearn {
  trainModels = async () => {
    const pool = Pool(() => spawn(new Worker('./Worker')));
    // ...do stuff with pool
  };
}

Error: Cannot find module 'engine-learn/Worker`

I am using @nrwl/esbuild:esbuild with Nx.

appocalypseltd avatar Feb 13 '23 14:02 appocalypseltd