Closed FHoxhaDev closed 6 months ago
Hi @modesty,
Is this an issue with Vercel or with the package itself? Is there any workaround to fix this error?
It's an issue with Vercel and executing this code on the server side due to edge functions. The issue is all of these files, the first of which you're seeing an error for, can't be read on the edge function because it hasn't been copied over by Vercel's edge function setup code. Vercel usually does a good job including what you need, but that's if you're importing code via module imports. This code is building up a string of all those file contents and eval'ing it.
I have a fork with a semi-working version that creates the big import file in a separate step, and then imports it into the main files so Vercel includes everything. I'm working on fixing an issue with a canvas function that's defined in one file and used in another that's not working, but you can try it out if you want. If I get it working today I'll create a PR in the main repo to get it merged into the baseline.
@FHoxhaDev Full fix is on this branch, try it out and let me know if it works for you:
"pdf2json": "github:kylerob/pdf2json#fix-createScratchCanvas-import"
It looked good in my tests.
@kylerob by pointing my "pdf2json" in package.json
will it point to your branch?
EDIT: it does resolve that issue. Thanks Kyle!
Hi @kylerob ,
Thank you for your fix. Unfortunately, for me it didn't work. It is failing at my API call where it uploads the file, this is my endpoint:
https://gist.github.com/FHoxhaDev/59e2dc2b1cc134b6d064b96573a51145
and this is the error:
Locally it works but not on Vercel host.
@FHoxhaDev Try forcing a redeploy on Vercel -- I ran into the same issue at first. Vercel seems to cache npm packages, because I've had trouble getting it to bring in my latest npm changes sometimes.
Hey @kylerob, thanks for your fix!
I just wanted to ask some quick questions.
I ask so we can install by doing a normal "pdf2json": "x.x.x" or even a "vercel-pdf2json": "x.x.x" instead of the current github thing
Cheers!
thanks to @kylerob. A more thorough fix plus appropriate tests are in PR #338, please review and test it out
@modesty Thanks for bringing it home!
fixed in 3.1.2
I'm facing this issue below when using my application in vercel. It works fine on localhost but it doesnt on vercel.
Error: