Open gandarufu opened 2 weeks ago
This is a NodeJS package, it's not meant to work in the browser.
In a browser, we can access the native <canvas />
element, so most of the logic in this library is not required
I'm having a similar issue - I'm not using it on the frontend, but instead in a Next.js / Webpack backend. I still get the same error:
Failed to parse document: Atel letter.pdf Error: Setting up fake worker failed: "Cannot find module '/sites/web/.next/server/vendor-chunks/pdf.worker.mjs' imported from /sites/web/.next/server/vendor-chunks/pdfjs-dist.js".
at eval (webpack-internal:///(rsc)/../node_modules/pdfjs-dist/legacy/build/pdf.mjs:8581:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Any advice would be appreciated, thanks!
I cannot get pdf-to-img working, I get the following error The file does not exist at "/node_modules/.vite/deps/build/pdf.worker.mjs?worker_file&type=module" which is in the optimize deps directory. The dependency might be incompatible with the dep optimizer. Try adding it to
optimizeDeps.exclude
.In another project I solved it by importing import * as pdfjsLib from "pdfjs-dist/webpack";
Would that be an option?