Uncaught SyntaxError: Unexpected token 'export' (at pdf.mjs:18148:10) with pdfjs-dist v4.0.379? #17618
Unanswered
lancejpollard
asked this question in
Q&A
Replies: 1 comment
-
Solved it. Ran into same issue. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I just had this working earlier today somehow, with
pdfjs-dist
in a Next.js 14 app router app. But it broke when I tried to deploy to vercel vercel/next.js#61549. So I upgraded to Next.js 14.11 canary, and got a different error with pdfjs-dist: vercel/next.js#61551 (Your target environment does not appear to support 'async/await'
).It all boils down to this at the end of the
pdfjs-dist/build/pdfjs.mjs
file:That
export
isn't liked, and neither is the top-levelawait
used throughout that file.So how do I get this to work in the browser? I tried doing a simple
<script src="/pdfjs/build/pdfjs.mjs"></script>
straight in an HTML file, and I get thatexport
error:Any ideas of a workaround, or how I can get this going in other ways?
In Next.js specifically, I tried adding pdfjs-dist to the
transpileModules
config option, and used a node_modules transpiler for Next.js, but they both had no effect.Eventually when try to dynamically import
pdfjs-dist
in my Next.js app, and call a function, I get this:Beta Was this translation helpful? Give feedback.
All reactions