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

Can't resolve 'encoding' in '......\node_modules\node-fetch\lib' #828

Closed
RaenonX opened this issue Sep 25, 2023 · 6 comments
Closed

Can't resolve 'encoding' in '......\node_modules\node-fetch\lib' #828

RaenonX opened this issue Sep 25, 2023 · 6 comments

Comments

@RaenonX
Copy link

RaenonX commented Sep 25, 2023

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

Describe the bug
I keep getting this error using next.js v13.4.19
image

Everything in tesseract.js works despite this warning.

According to https://stackoverflow.com/q/75438048/11571888, supabase/supabase-js#612 got this fixed. I am not using supabase unfortunately, so I still need to add encoding as dev dependency to remove the warning.

To Reproduce
Steps to reproduce the behavior:

  1. Clone https://github.com/RaenonX/tesseract-js-error-repro
  2. npm install
  3. npm dev
  4. Go to localhost:3000, or whatever shown in the console that invoked localhost:3000
  5. Warnings are printed out in the console

Expected behavior
No warning in next dev output.

Device Version:

  • OS + Version: Windows 11
  • Node v18

Additional context
N/A

@Balearica
Copy link
Member

Is this an issue on our end or with this particular framework? The links you provided seem to indicate the latter.

I can take a look at this, but I would need you to provide a repo + specific commands to run to reproduce as I am not familiar with this framework.

@RaenonX
Copy link
Author

RaenonX commented Sep 26, 2023

@Balearica Thanks for the response, updated my report

@Balearica
Copy link
Member

Thanks for preparing the example repo. I think this warning message is caused by some interaction between node-fetch and Next.js, and that fixing is outside of the scope of this project.

The node-fetch package, including the latest version, handles the fact that encoding may or may not be installed by trying to import is within a try block. Presumably Next.js is reporting this message to the console when the node-fetch developer did not intend this to be printed. This does not occur using the Node.js examples in this repo.

try {
	convert = require('encoding').convert;
} catch (e) {}

https://www.npmjs.com/package/node-fetch/v/2.7.0?activeTab=code

@RaenonX
Copy link
Author

RaenonX commented Sep 28, 2023

Oh, that's interesting to know. I'll try to file a next.js bug report. Is it OK if I leave this open for now?

@Balearica
Copy link
Member

Sure, we can leave this issue open for now.

@RaenonX
Copy link
Author

RaenonX commented Oct 1, 2023

Can't tell why, but next v13.5 is not showing this anymore, closing!

@RaenonX RaenonX closed this as completed Oct 1, 2023
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