Vercel: Issue with pdfjs-dist
Unanswered
Samir posted this in #help-forum
SamirOP
I've been trying to read content of pdf. It works fine on my pc but on vercel it says
I'm using
Setting up fake worker failed: "Cannot find module '/var/task/node_modules/pdf-text-reader/node_modules/pdfjs-dist/build/pdf.worker.mjs' imported from /var/task/node_modules/pdf-text-reader/node_modules/pdfjs-dist/build/pdf.mjs"
I'm using
pdf-text-reader
package which uses pdfjs-dist
underhood.8 Replies
try installing pdfjs-dist too
SamirOP
I did, still the same issue
And this process on happening on the server side
try dynamic importing the component with ssr: false, because this component can't be on the server
SamirOP
I mean its running for api route
SamirOP
After adding parallelism, I'm having the issue. I even tried setting max op at a time to 3 and still same issue
everything just works fine on my pc
SamirOP
I fixed the issue by downgrading to
pdfjs-dist@4.8.69
import * as pdfjsLib from "pdfjs-dist/build/pdf.min.mjs";
export async function extractPagesFromPDF(data: ArrayBuffer): Promise<Page[]> {
// @ts-ignore
await import("pdfjs-dist/build/pdf.worker.min.mjs");
}