Open kleenkanteen opened 3 days ago
silly mistake, @hyzyla/pdfium
was not in packag.json
edit: actually that did not fix it. same error
The minimal reproduction in the readme works locally. Not sure why the error occurs in the nextjs api route.
@kleenkanteen could you create small project to reproduce the error?
@hyzyla https://github.com/kleenkanteen/pdfium-issue-reproduction
Steps to reproduce:
pnpm install
then pnpm run dev
localhost:3000
. You will get the same error upon load.I forgot to add some code - just pushed a (more realistic) working reproduction
I've checked several times and found that the problem lies in this line of code and the Webpack configuration of the Next.js project:
scriptDirectory = require("url").fileURLToPath(new URL("./", import.meta.url));
![CleanShot 2024-10-17 at 19 22 10@2x](https://github.com/user-attachments/assets/3c19c697-5558-4b2b-b886-dbcb28d67462)
This line is a combination of Emscripten code and a Rollup transformation applied to it.
But that’s it for now 😔. I don’t know how to solve it yet. I'll try to take another look at this problem over the weekend, but no promises for now.
Np, I will try another library like pdf.js.
You might want to open a issue on the nextjs repo if you took a good look already. Someone there might be more familiar with this wizardry.
Am on windows 10 using pnpm.
I am using pdfium inside a nextjs app route api route endpoint. When I upload a pdf to the endpoint, hoping to turn it into a png, I get this error:
Here is the relevant code, I have installed both
pdfium
andsharp
: