Skip to content
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

Fix punycode deprecation warning #876

Open
cozykitten opened this issue Jan 20, 2024 · 2 comments
Open

Fix punycode deprecation warning #876

cozykitten opened this issue Jan 20, 2024 · 2 comments

Comments

@cozykitten
Copy link

Tesseract.js version (version number for npm/GitHub release, or specific commit for repo)
5.0.4

Describe the bug
When updating to node v21 this node warning comes up when using packages that rely on node's built in punycode module.
(node:15352) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

This module can be traced back to an old version of tr46 which itself is used in an old version of whatwg-url which itself is used in an old version of node-fetch.
tr46 already fixed that issue and newer versions of whatwg-url don't have the same issue and as far as I can tell the latest node-fetch version doesn't even use whatwg-url in the first place.

Long story short, would you consider updating to a newer version of node-fetch?

To Reproduce
Steps to reproduce the behavior:

  1. Update node to v21
  2. run project using tesseract.js
  3. See error

Device Version:

  • OS + Version: Windows 11 22H2
  • Node v21.6
@Balearica Balearica changed the title regarding the punycode deprecation warning Fix punycode deprecation warning Jan 22, 2024
@Balearica
Copy link
Collaborator

Thanks for looking into this. I looked into whether it is possible to remove this warning message by bumping the version of node-fetch, however I do not believe it is. Tesseract.js uses v2 of node-fetch.

  1. According to this issue, the depreciation warning is still an issue for the latest v2 release of node-fetch
  2. According to this documentation, using v3 of node-fetch would not be possible without adapting the project to use ESM modules rather than CommonJS
    1. The documentation states "We recommend you stay on v2 which is built with CommonJS unless you use ESM yourself. We will continue to publish critical bug fixes for it."

Therefore, I believe this warning will continue until either (1) there is v2 release of node-fetch that resolves it or (2) Tesseract.js switches to ESM modules. The latter will probably happen in the next major version, however is currently not a priority for me.

@cozykitten
Copy link
Author

Thank you, next major version sounds good enough.
For now I fixed it manually by going down the module tree and modifying the old version of tr46 and whatwg-url directly to use the userland punycode module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants