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

Cannot read properties of undefined (reading 'TessBaseAPI') #752

Closed
indersein-agilsoft opened this issue May 4, 2023 · 4 comments
Closed

Comments

@indersein-agilsoft
Copy link

const worker = await createWorker();
const rectangle = { left: 0, top: 0, width: 500, height: 250 };

(async () => {
await worker.loadLanguage('eng');
await worker.initialize('eng');
const {
data: { text }
} = await worker.recognize(
'https://tesseract.projectnaptha.com/img/eng_bw.png',
{ rectangle }
);
console.log(text);
await worker.terminate();
})();

I write this and return this

image

@Balearica
Copy link
Member

Please specify the version of Tesseract.js you are using in any bug reports, along with any other information that would be necessary to reproduce the behavior described.

I was unable to replicate this issue. I saved the following code into a file in the Node examples folder, and then ran the file out of that folder, and it ran as expected.

const { createWorker } = require('../../');

(async () => {
const worker = await createWorker();
const rectangle = { left: 0, top: 0, width: 500, height: 250 };
await worker.loadLanguage('eng');
await worker.initialize('eng');
const {
data: { text }
} = await worker.recognize(
'https://tesseract.projectnaptha.com/img/eng_bw.png',
{ rectangle }
);
console.log(text);
await worker.terminate();
})();
Mild Splendour
Mother of wil
I watch thy glid

@jonas-duarte
Copy link

The same is happening with me.

Node.js v18.15.0

Code:

const { createWorker } = require("tesseract.js");

(async () => {
  const worker = await createWorker();
  await worker.loadLanguage("eng");
  await worker.initialize("eng");
  const {
    data: { text },
  } = await worker.recognize("https://tesseract.projectnaptha.com/img/eng_bw.png");
  console.log(text);
  await worker.terminate();
})();

Error message:

D:\Projects\ball-sort-puzzle-bruteforce\node_modules\tesseract.js\src\createWorker.js:173
        throw Error(data);
        ^

Error: TypeError: Cannot read properties of undefined (reading 'TessBaseAPI')
    at ChildProcess.<anonymous> (D:\Projects\ball-sort-puzzle-bruteforce\node_modules\tesseract.js\src\createWorker.js:173:15)
    at ChildProcess.emit (node:events:513:28)
    at emit (node:internal/child_process:937:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

Node.js v18.15.0

package.json

{
  "dependencies": {
    "tesseract.js": "^2.1.0"
  }
}

@Balearica
Copy link
Member

Balearica commented May 18, 2023

@jonas-duarte Version 2.1.0 is an old/unsupported version that does not run on Node.js 18. The latest version at the time of this writing is v4.0.6. Please upgrade to the latest version of Tesseract.js (although anything v3 or higher should work).

I am closing this issue as I do not see any indication that this happens with supported versions of Tesseract.js.

@jonas-duarte
Copy link

It worked, thank you.

When I googled it, I was redirected to the v2.

@jonas-duarte Version 2.1.0 is an old/unsupported version that does not run on Node.js 18. The latest version at the time of this writing is v4.0.6. Please upgrade to the latest version of Tesseract.js (although anything v3 or higher should work).

I am closing this issue as I do not see any indication that this happens with supported versions of Tesseract.js.

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

3 participants