Dynamic require of "util" is not supported
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)
Same here.
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?
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
@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.
@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
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.