tesseract.js
tesseract.js copied to clipboard
Sveltekit TypeError
Bug Description
When using the npm module (v2.1.5) in a sveltekit project the server crashes with:
[path]\node_modules\tesseract.js\src\createWorker.js:173
throw Error(data);
^
Error: TypeError: Cannot convert undefined or null to object
at ChildProcess.<anonymous> ([path]\node_modules\tesseract.js\src\createWorker.js:173:15)
at ChildProcess.emit (node:events:390:28)
at emit (node:internal/child_process:917:12)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
(This only happens when trying to run in the browser e.g. via the onMount hook.
otherwise it runs fine in the browser until the status is "api initialized" it then only continues server-side and succeeds there
might be something to blame on vite etc. )
Steps to reproduce the behavior:
- create sveltekit project
npm init svelte@next .. - install tesseract module
npm i tesseract.js - import into svelte (or imported js/ts) file
- use
expected behaviour
The client side version of this module should be used to retrieve the text
feature request
converting this to a feature request in case i'm just not experienced enought (most probable):
please add an example project (similar to the vue/angular/react one) using sveltekit and this npm module.
If this issue is still active, please provide a reproducible example in the form of a code snippet or project repo that can be cloned.
i tried again with a newer svelte version, seems to work now, thanks
ok, the module works fine if used as a standalone (like in this mre)
but as soon as i try to export import this like here it doesnt work, seemingly because the svelte stores get triggered automatically initially on module import and that would trigger the worker creation (which doesnt work this early in the rendering yet) or something idk, but thats most probably on me since im not experienced with this