-
-
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
Attempted import error: 'create' is not exported from 'fontkit' (imported as 'fontkit'). #1991
Comments
I think the problem might be a typo: the latest package of fontkit is 2.0.2 |
Getting a same error message. |
I have same problem with version 3.0.0, old versions have same error |
Experiencing the same thing. Seems like a new version of react-pdf/font has been released that contains a breaking change. As the dependencies are listed using Notice the |
@eladonline @RajasekharReddy82 @rishipurwar1 If you're using renderer version Add:
To your Then add:
If you already have a resolutions object you'll just need to add this version to it. Notice there is no Then remove |
Also the above only worked for me when I made sure |
If i use mentioned version , will it work? |
@andyhmltn Thank you its works for me |
@andyhmltn Thank you for pointing out the problem, worked for me as well.
|
Thank you friend, u have made my day |
Same issue but fails with my build script in CodeBuild only. |
Worked for me, Thanks! |
your a life saver |
Any updates on this @diegomura - I can get it working locally but not when it compiles on our hosting service (use AWS Amplify for hosting) |
Any updates on this: @carlobeltrame @jeetiss @diegomura @adamduncan @PhilippMeissner We would all really really appreciate it! 😃 |
Can you try with the most recent version
@OlesKravchenko Are you working in Node or in the browser? Please provide a reproduction. "node_modules/@react-pdf/font": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@react-pdf/font/-/font-2.3.0.tgz",
"integrity": "sha512-+O1TR0gYnlJe3BUMVcT+5skAq7CwxgbiCPQneXmZbITeQMdqAVxPhVskIC7t3f7hg0YgZKG5e2L+11TD7uHbKQ==",
"dependencies": {
"@babel/runtime": "^7.16.4",
"@react-pdf/types": "^2.0.9",
"base64-to-uint8array": "^1.0.0",
"cross-fetch": "^3.1.5",
"fontkit": "^2.0.2",
"is-url": "^1.2.4"
}
}, "node_modules/@react-pdf/renderer": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@react-pdf/renderer/-/renderer-3.0.0.tgz",
"integrity": "sha512-1eTqNdl2+ZIC85L7NmPkUmyurZDLK1nernqvRlHVMMauB4rA3UkB0Y2Z8bHMUvB+t2s4rNlMJ+RZdrR5H/JGpw==",
"dependencies": {
"@babel/runtime": "^7.16.4",
"@react-pdf/font": "^2.3.0",
"@react-pdf/layout": "^3.2.0",
"@react-pdf/pdfkit": "^3.0.0",
"@react-pdf/primitives": "^3.0.0",
"@react-pdf/render": "^3.2.1",
"@react-pdf/types": "^2.1.0",
"queue": "^6.0.1",
"react-reconciler": "^0.23.0",
"scheduler": "^0.17.0"
},
"peerDependencies": {
"react": "^16.8.6 || ^17.0.0"
}
}, |
@carlobeltrame Is it not possible to fix without upgrading to 3.0.0? This should really be a major version upgrade for |
The only reason why it's a major version upgrade for @react-pdf/renderer is that support for Node 12 was dropped. It's really not a major upgrade in the classical sense. For the same reason, there is also no upgrade guide for upgrading to 3.0.0. There simply is nothing you would have to change in your code (unless you were using vite-plugin-shim-react-pdf before, in which case you would have to remove that when upgrading to 3.0.0). |
@carlobeltrame - tried upgrading to 3.0.0 and it fails to run in the browser with the same issue as everyone above. I can get it running in the browser with something like this below: But, that does not compile when we deploy it. |
Well, that's still not the most recent versions of the packages, see above my versions in package-lock. Not sure why it lets you keep the old versions, there might be something misconfigured in react-pdf. But if you force the same versions as me, do you keep having the error? Please note that @react-pdf/fontkit is discontinued, react-pdf switched back to using the original foliojs/fontkit package, so that package should no longer be installed when using renderer v3.0.0 |
@carlobeltrame - I added those packages without the ^. And added those resolutions as well. It was the only way I could get it running in the browser. any time I've installed @react-pdf/renderer@^3.0.0 - nothing will run. not even in the browser. I am seeing that when we install @react-pdf/renderer - it is adding in all the other @react-pdf libraries (not just /renderer). The actual compiling error is coming from @react-pdf/pdfkit/lib/pdfkit.browser.es.js |
Can you provide a minimal reproduction example in a git repositorysomewhere so I can check? |
Here is the pull request that updated react pdf in one of my projects: ecamp/ecamp3#2949 |
I still have same error even after doing what @andyhmltn suggested. |
I can't really share it right now but I just went ahead and updated pretty much everything - include node and npm
here node_modules/@react-pdf it does not contain @react-pdf/fontkit - so that's good I guess here is where errors are coming from: it seems like it is trying to use "fontkit", not @react-pdf/fontkit very unsure on what is going on so I am just throwing this out there... it seems like the issue is coming from fontkit specifically (NOT @react-pdf/fontkit) |
@marybbr - don't listen to me! I'm still not sure what is going on. Looking for answers |
digging into this deeper... does @carlobeltrame @Sebastian-Cor @andyhmltn or anyone else know how to get around this?? fontkit@1.9.0 - had a default export that named all the functions pretty sure this is where some of the issues are coming from. any ideas on getting around this? |
It is not just upgrading 1 package there are multiple dependencies associated with it like react, react history that might not be compatible with the codebase. This blanket approach can cause drastic breakage. In this case, the automatic uptick is the issue. Pushing a breaking new major version is fine as it gives the option to choose whether to move to the next or not. I think the author just needs to make the new fontkit only applicable to version v3.0 rather than anything for v2. |
@carlobeltrame the last version has the problem which this issue based on. I should have changed the version to prevent my code crashing and this was the only solution here which @andyhmltn suggested but still doesn't work for me. |
Ah I see, you were trying to downgrade. You would probably have to pin (using Anyways, the latest version does not have any problem if you upgrade correctly, using one of the two standard ways I described above. I am using it myself. If you do have a problem with 3.0.0, please someone provide a reproduction repository so we can fix the problem. Otherwise you will all be stuck with the old version forever... |
Ok so I have released a new package with the fix of reverting the latest commit to the previous version 2.3.0 and setting the sub dependencies to the exact version without uptick. Also, fixed the version for babel was incorrect that was not found. I have published a new package with these changes while maintaining credits to the author and contributors. It is working for me! Hope it unblocks you guys until this repo gets fix. For now, try out
|
@marybbr have you done a clean install? |
|
Alright guys, I am unsubscribing from notifications on this issue now, since it looks like you don't want the help of me or the maintainers of this package anymore. May I suggest we close this issue and you continue the discussion on @djaffer's repository, since it is not relevant anymore to @diegomura's react-pdf? @djaffer you might have to enable issues on your repository. |
There is no need for the issue to continue on mine. I have suggested the fix that is working for me to unblock myself and maybe other users can use it too. The issue still belongs to this repo. I am not going to maintain that repo and just have it as a workaround. Once this repo adopts the fix I can remove the package. |
I tried the same but it's not working in my case. My react version is 17.0.2. |
Just removing the
|
I'm encountering this issue too... |
Me too! please fix it.
|
I'm looking for an alternative, This package is awesome, but I don't want to deal with this type of issues. No offence to anyone though, I appreciate the Open Source work, but I'm having a hard time dealing with this package. |
Work here. Thanks. |
diegomura/react-pdf#1991 react-pdf/renderer broke because react-pdf/font package was updated solution is to set the version of font to 2.0.2
This also worked for me. Please pay attention to remove the ^ symbol from "@react-pdf/renderer"!! We spent a lot of time wondering why everyone says it's working and it didn't work for us... |
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 anyone using create-react-app, I got @react-pdf/renderer": "^3.0.0" working by updating react-scripts to 5.0.1 and "npm install --save buffer" No other react-pdf packages in my dependencies and nothing in my overrides or resolutions object. |
And do you have any reasoning for why do we need |
Hey guys, I found out over at #2028 that this error happens due to an issue in webpack 4. Upgrading to webpack 5 solved the problem there. Actually, it looks like @RossLYoung beat me to it with finding that, since react-scripts is likely the package which determines the webpack version in their project. But the buffer dependency should not be necessary. If you cannot update to webpack 5, you either have to eject and adjust your config as described here (or use craco or something similar to do that), or stay on @react-pdf/renderer < 3.0.0 until facebook/create-react-app#12605 or facebook/create-react-app#12021 is merged and released, and then update create-react-app. |
@vipindigiqt, once I had it nearly working with webpack 5 by updating react-scripts, I only had this buffer error #2016. @carlobeltrame, I had the same buffer error that you commented on in #2016 (comment) I hope that is of some use. |
Ah, true, there is still some buffer problem. I have PR #2023 open to fix that. Once that is merged and released, buffer shouldn't be necessary anymore. |
I am still getting this error with @react-pdf/renderer 3.0.0. |
I solved this by downgrading a bunch of packages and using the renderer v.2.0.19. Not sure if my solution is perfect but at least it worked for me. See my answer here: #2015 (comment) |
@marsmallos |
I tried this to upgrade from 2.3.0 but it didn't work for me. Is there any solution for 2.3.0? |
Have you fix above issue ? still got same problem? |
Updating webpack (react-scripts) to 5 opens another can of worms, webpack 5 no longer automatically polyfills some node.js modules. All webpack@5 compatible libraries should provide these polyfills. However, some older webpack@4 compatible libraries may not include these polyfills by default. To make these work with webpack@5, you need to manually add these modules ( If you're using create-react-app (react-scripts), you cannot under normal circumstances modify your webpack config, but I had some success using react-app-rewired to modify my webpack config, and node-polyfill-webpack-plugin to automatically add the polyfills I needed. Updating to webpack 5 and using |
After the upgradation, we are getting the below error in local and while deploying the code. Please help here.
Current version in our machine : @react-pdf/renderer": "^2.0.16"
@diegomura Please help check ASAP.
The text was updated successfully, but these errors were encountered: