Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not read from file: ...pdf.worker.min.js #47

Closed
advancedlogic opened this issue Jan 6, 2023 · 7 comments
Closed

Could not read from file: ...pdf.worker.min.js #47

advancedlogic opened this issue Jan 6, 2023 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@advancedlogic
Copy link

With the default example I see the pdf for 1 second and then I have error 504 (because it cannot find the file and timeouts) and I keep having this issue:

`✘ [ERROR] Could not read from file: /Users/user/Projects/Git/myproject/static/ui/node_modules/svelte-pdf/node_modules/pdfjs-dist/build/pdf.worker.min.js?url

node_modules/svelte-pdf/PdfViewer.svelte:45:24:
  45 │ ...rt pdfjsWorker from "pdfjs-dist/build/pdf.worker.min.js?url";`

I am using last version of Svelte/SvelteKit/Vite together with Tailwinds

@Gildedter
Copy link

Having the same issue, I took a look at #27, which says its fixed

my error looks likes this:

> npm run dev                                                                                                                                                                   > [email protected] dev                                                      > vite                                                                                  
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'Could not read from file: C:\\PROJECT_DIR\\node_modules\\pdfjs-dist\\build\\pdf.worker.min.js?url'
    }
  ],  warnings: []
}

Node.js v18.12.1

@vinodnimbalkar vinodnimbalkar added the help wanted Extra attention is needed label Jan 17, 2023
@eddyvinsensius
Copy link

does anyone know howto resolve this? , i'm having the same issue with just the default example and current version of sveltekit .. thanks.

@vinodnimbalkar
Copy link
Owner

Hi @eddyvinsensius ,
Please try to reproduce the same bug on stackblitz

@ricardoalcantara
Copy link

Hi, even the example doesn't work for me.

I am using Windows 10

pnpm --version
7.25.1

node --version
v18.12.1

C:\Projects\nodejs\svelte-pdf\example〉pnpm run dev                                                                                                                                          02/10/2023 12:58:14

> [email protected] dev C:\Projects\nodejs\svelte-pdf\example
> vite

Forced re-optimization of dependencies
Port 5173 is in use, trying another one...

  VITE v3.2.5  ready in 655 ms

  ➜  Local:   http://localhost:5174/
  ➜  Network: use --host to expose
✘ [ERROR] Could not read from file: C:\Projects\nodejs\svelte-pdf\example\node_modules\.pnpm\[email protected]\node_modules\pdfjs-dist\build\pdf.worker.min.js?url

    node_modules/.pnpm/[email protected]/node_modules/svelte-pdf/PdfViewer.svelte:39:24:
      39 │ import pdfjsWorker from "pdfjs-dist/build/pdf.worker.min.js?url";
         ╵                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

12:58:19 [vite-plugin-svelte] prebundle libraries in progress ...
C:\Projects\nodejs\svelte-pdf\example\node_modules\.pnpm\[email protected]\node_modules\esbuild\lib\main.js:1575
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 1 error:
node_modules/.pnpm/[email protected]/node_modules/svelte-pdf/PdfViewer.svelte:39:24: ERROR: Could not read from file: C:\Projects\nodejs\svelte-pdf\example\node_modules\.pnpm\[email protected]\node_modules\pdfjs-dist\build\pdf.worker.min.js?url
    at failureErrorWithLog (C:\Projects\nodejs\svelte-pdf\example\node_modules\.pnpm\[email protected]\node_modules\esbuild\lib\main.js:1575:15)
    at C:\Projects\nodejs\svelte-pdf\example\node_modules\.pnpm\[email protected]\node_modules\esbuild\lib\main.js:1033:28
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: {
        column: 24,
        file: 'node_modules/.pnpm/[email protected]/node_modules/svelte-pdf/PdfViewer.svelte',
        length: 40,
        line: 39,
        lineText: 'import pdfjsWorker from "pdfjs-dist/build/pdf.worker.min.js?url";',
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'Could not read from file: C:\\Projects\\nodejs\\svelte-pdf\\example\\node_modules\\.pnpm\\[email protected]\\node_modules\\pdfjs-dist\\build\\pdf.worker.min.js?url'
    }
  ],
  warnings: []
}

Node.js v18.12.1
 ELIFECYCLE  Command failed with exit code 1.

@vinodnimbalkar
Copy link
Owner

look like an issue with vite, please ref: vitejs/vite#10838

@antoineMagentine
Copy link

antoineMagentine commented Mar 13, 2023

Hi, I was looking at this because I had the same issue. react-pdf had the same problem and they fixed it by removing the ?url at the end of the pdfJsWorker import url (not supported by Vite). Maybe that'll help you, here's how they fixed it :
wojtekmaj/react-pdf@v6.0.1...v6.0.2

It worked for me :)

@vinodnimbalkar
Copy link
Owner

Thanks @antoineMagentine
This issue was fixed by #50 so closing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants