zapolnoch / node-tesseract-ocr

A Node.js wrapper for the Tesseract OCR API
MIT License
304 stars 38 forks source link

Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed #34

Open TejasLamba2006 opened 2 years ago

TejasLamba2006 commented 2 years ago

My code

const tesseract = require("node-tesseract-ocr")

const config = {
  lang: "eng",
  oem: 1,
  psm: 3,
}

const img = "https://tesseract.projectnaptha.com/img/eng_bw.png"

tesseract
  .recognize(img, config)
  .then((text) => {
    console.log("Result:", text)
  })
  .catch((error) => {
    console.log(error.message)
  })

Error

Command failed: tesseract stdin stdout -l eng --oem 1 --psm 3
/bin/sh: 1: tesseract: not found

events.js:291
      throw er; // Unhandled 'error' event
      ^

Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
    at doWrite (_stream_writable.js:399:19)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at IncomingMessage.ondata (_stream_readable.js:718:22)
    at IncomingMessage.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at IncomingMessage.Readable.push (_stream_readable.js:213:10)
    at HTTPParser.parserOnBody (_http_common.js:135:24)
    at TLSSocket.socketOnData (_http_client.js:474:22)
Emitted 'error' event on Socket instance at:
    at errorOrDestroy (internal/streams/destroy.js:108:12)
    at Socket.onerror (_stream_readable.js:754:7)
    at Socket.emit (events.js:314:20)
    at errorOrDestroy (internal/streams/destroy.js:108:12)
    at onwriteError (_stream_writable.js:418:5)
    at onwrite (_stream_writable.js:445:5)
    at doWrite (_stream_writable.js:399:11)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at IncomingMessage.ondata (_stream_readable.js:718:22) {
  code: 'ERR_STREAM_DESTROYED'
}
abdul-qadeer-mern commented 2 years ago

I am facing the same issue.