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.

Cannot find module 'worker_threads'

See original GitHub issue

When I run npm run build, I get below error

> @ build /Users/ajayposhak/Projects/foo
> wmr build --prerender

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'worker_threads'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/Users/ajayposhak/Projects/foo/node_modules/wmr/wmr.cjs:2:266)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ build: `wmr build --prerender`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ajayposhak/.npm/_logs/2020-12-03T08_39_59_702Z-debug.log

Node version is v10.16.3, so I think minimum required version to use wmr should be node v15.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
AjayPoshakcommented, Dec 3, 2020

It goes away when I upgrade my node to version 15. I think it would be great to mention this in documentation and/or have a engines field in package.json. I’ll be happy to open a PR for this.

0reactions
lukeedcommented, Dec 3, 2020

Ah. Well 12 has the same ESM impl as 14. You probably ran into issues with the 13.0-13.7 range, which has borked exports map support

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module 'worker_threads' error in production
The code works fine when I run npm start in VS Code. But when build and copied in Ubuntu server, it show "Cannot...
Read more >
Cannot find module 'worker_threads' - Glitch Support
Worker threads are only supported in node 10.5.0+ - can you check what version of node you're using by running node --version in...
Read more >
Cannot find module 'worker_threads' in v1.1.46 using GitHub ...
That CI pipeline is using Node v10, which only offers worker threads with the --experimental-worker flag. It's available by default in v11+. I ......
Read more >
Using worker_threads in Node.js - Medium
^Error: Cannot find module 'worker_threads' at Function.Module. ... It is true if we are in the main thread (that is, not in a...
Read more >
FabioRosado | Fix worker_threads module missing
How to fix the error "Cannot find module 'worker_threads'". Table of Contents. The Problem; The solution. At Coiled we use a few hooks...
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