Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic require of "util" is not supported #654

Open
ralyodio opened this issue Sep 1, 2022 · 6 comments
Open

Dynamic require of "util" is not supported #654

ralyodio opened this issue Sep 1, 2022 · 6 comments

Comments

@ralyodio
Copy link

ralyodio commented Sep 1, 2022

I'm getting this error using adapter-node with sveltekit after upgrading to latest.

Dynamic require of "util" is not supported

Here's the node error:


$ node build/index.js 
Listening on 0.0.0.0:3000
Error: Dynamic require of "util" is not supported
    at file:///home/ettinger/www/grazily.com/grazily-ui/build/server/chunk-BHN6OJC3.js:12:9
    at node_modules/natural/lib/natural/tokenizers/aggressive_tokenizer.js (file:///home/ettinger/www/grazily.com/grazily-ui/build/server/chunk-METZWSI6.js:239:16)
    at __require2 (file:///home/ettinger/www/grazily.com/grazily-ui/build/server/chunk-BHN6OJC3.js:15:50)
    at node_modules/natural/lib/natural/phonetics/phonetic.js (file:///home/ettinger/www/grazily.com/grazily-ui/build/server/chunk-METZWSI6.js:255:21)
    at __require2 (file:///home/ettinger/www/grazily.com/grazily-ui/build/server/chunk-BHN6OJC3.js:15:50)
    at node_modules/natural/lib/natural/phonetics/soundex.js (file:///home/ettinger/www/grazily.com/grazily-ui/build/server/chunk-METZWSI6.js:285:20)
    at __require2 (file:///home/ettinger/www/grazily.com/grazily-ui/build/server/chunk-BHN6OJC3.js:15:50)
    at node_modules/natural/lib/natural/index.js (file:///home/ettinger/www/grazily.com/grazily-ui/build/server/chunk-METZWSI6.js:12623:23)
    at __require2 (file:///home/ettinger/www/grazily.com/grazily-ui/build/server/chunk-BHN6OJC3.js:15:50)
    at node_modules/in-a-nutshell/lib/in-a-nutshell.js (file:///home/ettinger/www/grazily.com/grazily-ui/build/server/chunk-METZWSI6.js:12683:19)
@SachaG
Copy link

SachaG commented Oct 19, 2022

Same here.

@Hugo-ter-Doest
Copy link
Collaborator

I checked the source files that are mentioned in your stack trace. But I don't see a dynamic require of util. Any clue what is going on?

@adaboese
Copy link

Getting:

chunk-WGAPYIUP.js?v=ac96e19a:13 Uncaught Error: Dynamic require of "webworker-threads" is not supported
    at chunk-WGAPYIUP.js?v=ac96e19a:13:9
    at node_modules/.pnpm/[email protected]/node_modules/natural/lib/natural/classifiers/classifier_train_parallel.js (classifier_train_parallel.js:6:13)
    at __require2 (chunk-WGAPYIUP.js?v=ac96e19a:19:50)
    at 

@adaboese
Copy link

@Hugo-ter-Doest Would it be possible to re-open?

I am unable to use this library in Remix at the moment.

Happy to help troubleshooting.

@mkappelhof
Copy link

mkappelhof commented Mar 26, 2024

@adaboese How do you use it in Remix?

I have the exact same issue when using Natural in a Remix action. The weird thing is though that everything works fine when i POST data to the route with the action, but when i perform a Get request to the route, i get the same Dynamic require of "webworker-threads" is not supported error.

The same code however works fine & without issues when i run it directly on Node.js so i'm probably doing something wrong or it is an issue with Remix

@Hugo-ter-Doest
Copy link
Collaborator

Hugo-ter-Doest commented Mar 26, 2024

Oke, let's have a look.

Webworker threads are not dynamically required, a try-catch construct is used:

try {
  Threads = require('webworker-threads')
} catch (e) {
  // Since webworker-threads are optional, only thow if the module is found
  if (e.code !== 'MODULE_NOT_FOUND') throw e
}

So it always tries to load the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants