-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Console error: Attempted import error: 'create' is not exported from 'fontkit' (imported as 'fontkit'). after upgrading @react-pdf/renderer to 3.0.0 #2015
Comments
+1 to this. I'm happy with the package for now, but It's preventing me from updating my webpack (react-scripts package) to 5. I was waiting for an update, it did update, but Now I'm facing this fontkit error as mentioned by @marsmallos |
Using React version
"overrides": {
"@react-pdf/font": "2.2.1",
"@react-pdf/pdfkit": "2.1.0"
} Note that I am using // other stuff in the package.json file
"dependencies": {
// other dependencies in the package.json file
"@react-pdf/renderer": "3.0.0"
}
"overrides": {
"@react-pdf/font": "2.2.1",
"@react-pdf/pdfkit": "2.1.0"
}
// other stuff in the package.json file And everything worked fine after that |
For React version 16.15.1 with yarn and @react-pdf/renderer": "3.0.0 This is if you are using yarn for npm users you can use the @RrNn fix Added an resolutions key to your package.json that looks like;
So, finally you will have a package.json that looks like;
|
For Yarn users simply replace "overrides" with "resolutions" |
Omg @RrNn you are my hero, your fix worked for me! I had been stuck on this for almost a week. It now works when I run the react app in firefox. When trying to run it in electron, however, I get "RangeError: Array buffer allocation failed" and it seems to be related to reactpdf renderer. I'm thinking of switching from this package since it's currently not working properly, does anybody know any alternatives? |
Unfortunately "overrides"/"resolutions" solution breaks |
Hey guys, over at #2028 I found out that this is most likely an issue with webpack 4. Upgrading to webpack 5 at the same time as react-pdf 3.0.0 fixed the problem there. Can you try that? |
As I said in my previous comment, the problem is not with the webpack itself, but rather with default |
@dhananjay-nickelfox Yes, as stated above, you will have to update to Webpack 5, or stay on @react-pdf/renderer v2.x until Webpack 4 has fixed their .cjs file compatibility. |
@carlobeltrame Have downgraded it to 2.x version and webpack 4.. Still facing the same issue. Any suggestion? |
npm 6.14.11 and react version 17.0.2 Tried above but still got this: |
After lots of additional issues all starting from my unfortunate initial decision to upgrade this package to v.3.0.0 (I'm on webpack 4) my fix ended up being
"dependencies": { "overrides": { And doing npm install again Don't ask me why this worked because I don't know. It might not work for you. |
Thanks for your update! |
Fix by updating react scripts to v5. Other overrides/resolution fixes break down Image rendering. |
I tried the @RrNn answer but didn't work for me, i guess i will try with another package. [my react V: 18, my node V: 16] |
@bansaj I'm rendering images in my PDF:s using the overrides/versions I mentioned above |
For me @react-pdf/renderer 3.0.0. didn't work because this version require @react-pdf/pdfkit 3.0.0 which creates error. Highest working version of @react-pdf/renderer (which didn't require problematic pdfkit) is 2.2.0 "dependencies": { "overrides": { |
I had got the same issue. Nothing worked. But finally [marsmallos]'s solution worked for me. |
@carlobeltrame |
@gyanvector it's not an issue with the node version, but with webpack 4. Upgrading to webpack 5 will resolve the problem. |
@carlobeltrame But before updating node to |
That means you must have at the same time updated @react-pdf/renderer from 2.x to 3.x. What's in your package.json, and do you use a package-lock.json which you check into version control? |
Could someone help as this has been installed and now has messed up a hi-charts variable pie chart SVG that I was rendering in the PDF, it's created a border all around the SVG and I believe its from installing - all these packages as I only had @react-pdf/renderer installed before, then it's been coming up with this error on this issue. so I've installed them extra ones mentioned - also added in fix the error but has cause my PDF to have this Strange border around the outside of the variable pie... and I haven't added in any border to styles.. |
Yes, this solution breaks Image. I need to put some images in my pdf, and I cannot upgrade to WebPack5, I really need a solution to make Image works. |
Webpack 4 was released in February 2018, and the last v4 version of webpack was released in September of 2020. Sorry to say, but Webpack 5 has been around for longer than webpack 4's entire lifespan. So we might be closer to webpack 6 than to webpack 4 by now. I think it's safe to say not many open source maintainers will have time to help with setups which have been outdated for 3 years. |
This is my fix for To apply fix:
PS: If you have tried overrides solution first: revert the overrides back What fix does: It adds support for the |
Why has this broken a version I was using though. it was all fine. then it starting showing an error and I installed these extra packages and it has now created a border around my rendered SVG that displays in the PDF. I never upgraded any of the packages. |
I have tried following your steps ...but getting same error. as below I have tried following your steps ...but getting same error. as below |
Make sure that during npm install it says something like this:
Here is bare minimum project with the applied fix https://github.com/evgsil/react-pdf-webpack4-bugfix |
I feel there is some version issue..a s i did all process again. Please check below ss |
It seems that you are not using react-scripts at all, it means that your application has not been created using create react app or was ejected. It is hard to tell without knowing your project setup, but you need update or create webpack.config.js and apply changes there manually |
I have used CRA for my project |
which version of |
it is same...what you have used |
Could you try to run |
its successfully compiles dear. Thanks a lot for demo repo. it helps a lot to fix the issue.. everything works fine now. I cloned my repo again, then did one by one process again . and its successfully done now. |
What about rending Images and SVGS they still have something wrong with them, Creating a strange border... |
Have you solved this problem yet |
Did you find the answer? |
my node version is 18.16.1 dep:{
|
Hello,
After updating @react-pdf/renderer from 2.0.2 to 3.0.0 in my react app I'm getting the following error in the console, and the react website freezes:
I have tried updating the fontkit package to the latest version but it already was the latest version. My node version is v16.13.2. Please help.
The text was updated successfully, but these errors were encountered: