Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 935 Bytes

File metadata and controls

31 lines (22 loc) · 935 Bytes

Post-Installation Setup

After running npm install, you need to copy the PDF.js worker file to make PDF processing work:

Windows (PowerShell)

Copy-Item -Path "node_modules\pdfjs-dist\build\pdf.worker.min.mjs" -Destination "public\pdf.worker.min.mjs"

macOS/Linux (Bash)

cp node_modules/pdfjs-dist/build/pdf.worker.min.mjs public/pdf.worker.min.mjs

Why is this needed?

The PDF.js library requires a web worker to process PDF files. This worker must be served from the public directory so it can be loaded by the browser.

Automation (Optional)

You can add this to your package.json scripts:

{
  "scripts": {
    "postinstall": "cp node_modules/pdfjs-dist/build/pdf.worker.min.mjs public/pdf.worker.min.mjs || copy node_modules\\pdfjs-dist\\build\\pdf.worker.min.mjs public\\pdf.worker.min.mjs"
  }
}

This will automatically copy the worker file after every npm install.