Neeraj Negi
Neeraj Negi

Reputation: 11

Aborted(Error: ENOENT: no such file or directory[...])

I'm getting this issue after deploying my code on vercel;it was working completely fine in my local environment. I'm not able find solution for this problem anywhere.

Aborted(Error: ENOENT: no such file or directory, open '/var/task/node_modules/tesseract.js-core/tesseract-core-simd.wasm') 2023-01-04T06:54:46.648Z 7c70e537-4119-465d-924c-f90026df64fc ERROR Uncaught Exception {"errorType":"RuntimeError","errorMessage":"Aborted(Error: ENOENT: no such file or directory, open '/var/task/node_modules/tesseract.js-core/tesseract-core-simd.wasm'). Build with -sASSERTIONS for more info.","stack":["RuntimeError: Aborted(Error: ENOENT: no such file or directory, open '/var/task/node_modules/tesseract.js-core/tesseract-core-simd.wasm'). Build with -sASSERTIONS for more info."," at n (/var/task/node_modules/tesseract.js-core/tesseract-core-simd.js:18:375)"," at Ua (/var/task/node_modules/tesseract.js-core/tesseract-core-simd.js:19:317)"," at /var/task/node_modules/tesseract.js-core/tesseract-core-simd.js:20:394"]} Unknown application error occurred Runtime .Unknown

I used tesseract.js package and it was working good on my local environment, but not on Vercel production server

Upvotes: 1

Views: 888

Answers (2)

domzo
domzo

Reputation: 1

I just tested and everything works, I started a new Next.js project with

npx create-next-app@latest

then added tesseract.js to the project

npm install tesseract.js

this is what the simple index.js file looks like

import Tesseract from "tesseract.js";

Tesseract.createWorker({
  logger: (message) => {
    console.log(message);
  },
});
let file = [];

const recognize = async () => {
  const {
    data: { text },
  } = await Tesseract.recognize(file, "eng");
  console.log(text);
};

const onFileChange = (event) => {
  const input = event.target.files;
  file = input[0];
  console.log(file);
  recognize();
};

export default function Home() {
  return (
    <>
      <input type="file" onChange={(e) => onFileChange(e)} />
    </>
  );
}

I tested both on local environment and vercel production server and all should work. Hope it helps

Upvotes: -1

domzo
domzo

Reputation: 1

Based on the above, I think that the problem is that you are importing createWorker

import { createWorker } from "tesseract.js";

try to change the import to

import Tesseract from "tesseract.js";

and then use it like

Tesseract.createWorker();
//image- path of image you want to use, lang- language you want to use
Tesseract.recognize(image, "lang");

Upvotes: 0

Related Questions