question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not resolve import "worker_threads" when trying to use in web

See original GitHub issue

Hi 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:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
maxevilmindcommented, Nov 16, 2020

yep, import works perfectly now thank you for adding the changes!

1reaction
maxevilmindcommented, Nov 13, 2020

@101arrowz amazing! thank you for pushing it quickly! I will test it out today

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found