dimdenGD / chrome-lens-ocr

Library to use Google Lens OCR for free, via API used in Chromium.
169 stars 6 forks source link

Cannot use require to use the module #20

Open huy19th opened 1 month ago

huy19th commented 1 month ago

I'm using typescript for my project and when it compiles, import() statement was converted to require() so i ran into this error

D:\Git\comic-ocr-translation-web\dist\modules\ocr-translation\ocr-translation.service.js:12 const chrome_lens_ocr_1 = require("chrome-lens-ocr"); ^

Error [ERR_REQUIRE_ESM]: require() of ES Module D:\Git\comic-ocr-translation-web\node_modules\chrome-lens-ocr\src\index.js from D:\Git\comic-ocr-translation-web\dist\modules\ocr-translation\ocr-translation.service.js not supported. Instead change the require of index.js in D:\Git\comic-ocr-translation-web\dist\modules\ocr-translation\ocr-translation.service.js to a dynamic import() which is available in all CommonJS modules.
at Object. (D:\Git\comic-ocr-translation-web\dist\modules\ocr-translation\ocr-translation.service.js:12:27) { code: 'ERR_REQUIRE_ESM' }

dimdenGD commented 1 month ago

Make it compile to ESM instead