I am trying to use node.js 'worker_threads' library with Node v14.15.1 and getting this error
Cannot find module 'worker_threads' or its corresponding type declarations.ts(2307)
tsc
src/api/services/email.service.ts:1:62 - error TS2307: Cannot find module 'worker_threads'.
1 import { Worker, isMainThread, parentPort, workerData } from 'worker_threads';
Found 1 error.
my code -
import { Worker, isMainThread, parentPort, workerData } from 'worker_threads';
worker threads got stable after node 11. So it should work. What am i doing wrong ?
PS - I ran same code with JS and it worked fine so i don't think its Node.js issue. Other core libraries like fs are also working fine. Do I need any additional config for TS ?
npm install @types/node
or the equivalent command for your package manager of choice. – Pye