-
-
Notifications
You must be signed in to change notification settings - Fork 905
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
Node error Importing a react-pdf component into page using new nextjs app directory #1532
Comments
Check #1508 maybe the fix in there will help you? |
i'm in the same situation with a brand new nextJS app route project. |
@abduljamac #1508 (comment) this worked for me! |
Did it work without using DynamicOptions from next? |
I've used it so as to avoid ssr, dunno if it works without it |
ok - so following the docs (latest) using react 18 I have to use the CDN url for pdfjs.GlobalWorkerOptions.workerSrc = when using react-pdf I get the following error .6.172" does not match the Worker version "3.8.162" Using the CDN URL worked so I assume you could download the latest worker and reference that instead of using the CDN |
@emiller7 The error you're getting suggests to me that you have installed pdfjs-dist separately and in fact you have two copies of pdfjs-dist installed in your repository. I'd suggest you fix that. |
@wojtekmaj yes your correct - for some reason pdfjs-dist keeps appearing in my node_modules folder even though I did not npm install it or include it in my package.json - trying to figure out how to remove it |
@wojtekmaj actually when doing npm install react-pdf it also installs pdfjs-dist folder into my node_modules folder with version 3.6.172. The version in the react-pdf folder in node_modules uses a newer version 3.8.162. It seems like the dependency on pdfjs-dist when installing react-pdf is using the older version. Thus doing npm install pdfjs-dist will update to the latest version 3.8.162 I did a succesful npm uninstall pdfjs-dist and then did a npm install pdfjs-dist@3.6.172 and it worked |
Since the original issue has been resolved and the solution has been properly documented in README, I'm closing this. |
Before you start - checklist
Description
My project is using the new app directory for next-js, I created component which contains react-pdf code, that looks like this:
and when I import it into page.tsx, I get the error below:
However it works fine in non app directory project, so I assume its problem with next-js app directory not being compatible with react-pdf. I was wondering if anyone experienced this problem and if they have a work around?
Steps to reproduce
N/A
Expected behavior
To not show the error?
Actual behavior
N/A
Additional information
No response
Environment
The text was updated successfully, but these errors were encountered: