Could not resolve import "worker_threads" when trying to use in web
See original GitHub issueHi everyone,
I am trying to use the library as an ESM module like that:
import * as fflate from 'fflate';
But I am getting Error: Could not resolve import "worker_threads" in "../../../node_modules/fflate/esm/node-worker.js".
In esm/index.js
I see the following line import wk from './node-worker';
and if I change it to import wk from './worker';
it works fine.
As I understand it tries to run node version worker in web for some reason. Does it miss some sort of condition to import proper worker?
I really need this so I am ready to work out a PR for that.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Ts-node using worker_thread cause `cannot use import ...
Apparently when I try to run the file with ts-node thread.ts , i got this error: (node:13200) Warning: To load an ES module,...
Read more >Support Web Workers · Issue #43583 · nodejs/node
Sometimes I would like to offload CPU heavy work to a worker (important to keep servers and apps responsive). However, because it's such...
Read more >Using worker_threads in Node.js
This is a beginner's guide to using worker_threads in Node.js. It does not assume you already understand Web Workers. (The API for worker_threads...
Read more >Using Web Workers - Web APIs - MDN Web Docs
Web Workers are a simple means for web content to run scripts in background threads. The worker thread can perform tasks without interfering ......
Read more >Using instrumented clients in worker threads - AWS X-Ray
As a result, when you try to use the instrumented AWS SDK for Java client ... Failed to begin subsegment named 'AmazonSNS': segment...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yep, import works perfectly now thank you for adding the changes!
@101arrowz amazing! thank you for pushing it quickly! I will test it out today