hrynko / vue-pdf-embed

PDF embed component for Vue 2 and Vue 3
https://npmjs.com/package/vue-pdf-embed
MIT License
712 stars 109 forks source link

The requested module 'pdfjs-dist' does not provide an export named 'PasswordResponses' #209

Closed ndrbrt closed 5 months ago

ndrbrt commented 5 months ago

I just tried the basic example in the README and got this error:

 ERROR  The requested module 'pdfjs-dist' does not provide an export named 'PasswordResponses'

  import { PasswordResponses } from "pdfjs-dist";
  ^^^^^^^^^^^^^^^^^
  SyntaxError: The requested module 'pdfjs-dist' does not provide an export named 'PasswordResponses'
  at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
  at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
  at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
  at async ViteNodeRunner.interopedImport (node_modules/@nuxt/vite-builder/node_modules/vite-node/dist/client.mjs:383:28)
  at async ViteNodeRunner.directRequest (node_modules/@nuxt/vite-builder/node_modules/vite-node/dist/client.mjs:253:24)
  at async ViteNodeRunner.cachedRequest (node_modules/@nuxt/vite-builder/node_modules/vite-node/dist/client.mjs:189:14)
  at async ViteNodeRunner.dependencyRequest (node_modules/@nuxt/vite-builder/node_modules/vite-node/dist/client.mjs:233:12)
  at async pages/pdf.vue:1:31
  at async ViteNodeRunner.runModule (node_modules/@nuxt/vite-builder/node_modules/vite-node/dist/client.mjs:362:5)
  at async ViteNodeRunner.directRequest (node_modules/@nuxt/vite-builder/node_modules/vite-node/dist/client.mjs:346:5)
ndrbrt commented 5 months ago

It turns out that this error occurs only in SSR mode. Forcing client-side rendering solves the problem. My bad.

clarkio commented 4 months ago

@ndrbrt I'm running into the same issue with Astro. How did you force client-side rendering for your project? In Astro I set client:load but I'm still running into this error.

ndrbrt commented 4 months ago

@clarkio I'm not familiar with Astro. In Vue+Nuxt I used <ClientOnly>

<ClientOnly>
  <VuePdfEmbed ... />
</ClientOnly>