-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
NextJS project fails to build when using Tesseract.js #868
Comments
Another simple way to reproduce the issue without having to clone a repo:
|
When I ran your repo I got a file path (
For context, Tesseract.js "workers" get their own web worker (browser) or worker thread (Node.js), which is independent code that uses a different entry point. When Tesseract.js is used on its own, this entrypoint should be identified automatically. However, this may not hold with build systems implemented by various frameworks, as these build systems copy around files in a way that violates Tesseract.js's assumptions for where files are located. |
That is actually very helpful information. It works now. Thanks a lot :-) |
I encountered this issue and setting workerPath didn't help. I fixed the issue by adding |
In my case, I modified
|
Tesseract.js version (version number for npm/GitHub release, or specific commit for repo)
5.0.4
Describe the bug
A NextJS app using tesseract.js will fail to build with error
Cannot find module '/my-dev-folder/.next/server/app/worker-script/node/index.js'
To Reproduce
Steps to reproduce the behavior:
yarn install
to install the dependenciesyarn build
to build the NextJS appExpected behavior
I would expect to be able to use tesseract.js in a NextJS application.
Device Version:
Additional context
The project was created using
npx create-next-app@latest tesseract-js-nextjs
and accepting all the default values. The file that uses tesseract.js is/src/app/api/tesseract/route.ts
. It includes reading a file into a buffer, creating a worker and then recognizing the buffer, but in reality, only creating the worker is enough to make the build fail.The text was updated successfully, but these errors were encountered: