zapolnoch/node-tesseract-ocr

Error: Unhandled 'error' event write EOF ... Emitted 'error' event on Socket instance at:

vivien7512 opened this issue · 3 comments

On Windows 10 and windows 11:

the basic example dos not works well

npm install node-tesseract-ocr
npm install fs.promises

const tesseract = require("node-tesseract-ocr");
const fs = require("fs/promises");

async function main() {
  const img = await fs.readFile("image.png");
  const text = await tesseract.recognize(img);

  console.log("Result:", text);
}

main();

The basic example generate an error :

node index.js
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: write EOF
    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4095,
  code: 'EOF',
  syscall: 'write'
}

Node.js v18.12.1

Haivng the same issue, any luck fixing it?

Install tesseract on your machine first.
Check installation with tesseract -v

I had to restart my IDE and manually add it to the PATH variable.