Open sahanatvessel opened 2 months ago
Under Next.js@14.2.1 and pdf-dist@3.1.81:
I copied the worker file from node_modules to the public folder (static assets).
cp /node_modules/pdfjs-dist/legacy/build/pdf.worker.js /public/pdf.worker.js
And then for server side I explicitly defined the worker: pdfjsLib.GlobalWorkerOptions.workerSrc = process.cwd() + '/public/pdf.worker.js';
Turned out the absolute path with process.cwd() is important for the production build.
Error processing file: Error: Setting up fake worker failed: "Cannot find module './pdf.worker.js' Require stack: