diegomura / react-pdf

📄 Create PDF files using React
https://react-pdf.org
MIT License
14.89k stars 1.18k forks source link

DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead. #2925

Open cduff opened 2 days ago

cduff commented 2 days ago

Using @react-pdf/renderer@4.0.0 with node 22.11.0 results in the following console output:

[DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

Using --trace-deprecation gives me:

at Object.<anonymous> (C:\project\node_modules\node-fetch\node_modules\whatwg-url\lib\url-state-machine.js:2:18)

And then npm list node-fetch gives me:

app-server@ C:\project
└─┬ @react-pdf/renderer@4.0.0
  └─┬ @react-pdf/font@3.0.0
    └─┬ cross-fetch@3.1.8
      └── node-fetch@2.7.0
jpainam commented 2 days ago

This is not related to this package. See here https://github.com/yarnpkg/yarn/issues/9005

cduff commented 1 day ago

Thanks for your comment @jpainam, but I'm not sure how this relates to yarn?

From what I can work out it's caused by @react-pdf/font depending on cross-fetch which has this issue - it relies on an old version of node-fetch which causes the punycode deprecation warning. I tested the latest version of node-fetch and it no longer causes the punycode warning.

Unfortunately, it looks like the latest version of cross-fetch (v4.0.0) still has this issue as it still depends on an old version (v2.7.0) of node-fetch.

So, options for @react-pdf/font would be to either:

florianbepunkt commented 14 hours ago

Is there a need for cross-fetch at all? Current LTS versions of node support native fetch.