I'm trying to build an Electron/Webpack app that uses Tesseract.js for OCR, but when I call Tesseract.createWorker, I get this error message:
A JavaScript error occured in the main process.
Uncaught Exception: TypeError: __webpack_require__.g.addEventListener is not a function...
This is the code that I'm trying to use to create the Tesseract worker (in the main thread):
const worker = await Tesseract.createWorker({
workerPath: new URL('../node_modules/tesseract.js/dist/worker.min.js', import.meta.url),
logger: m => console.log(m)
});
This project is based on the webpack-typescript Electron Forge quickstart.
I have tried changing the URL to workerPath to point directly to the tesseract.js worker script with an absolute path, but I got the same error.