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

2.x: Specify encoding as an optional peer dependency in package.json #1310

merged 2 commits into from Nov 5, 2021


Copy link

@ciffelia ciffelia commented Sep 23, 2021

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • New feature
  • Other, please explain:

What changes did you make? (provide an overview)

I installed node-fetch 2.x on my project with Yarn 2 (aka Yarn berry). When I call require('node-fetch'), I get this warning message:

(node:22404) [MODULE_NOT_FOUND] Error: node-fetch tried to access encoding, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

It seems that encoding package is optional and only used in body.textConverted() method (discussed in #412).

So I added the following to package.json of node-fetch:

"peerDependencies": { 
    "encoding": "*"
"peerDependenciesMeta": {
    "encoding": {
        "optional": true

Which issue (if any) does this pull request address?

Is there anything you'd like reviewers to know?

package.json Outdated Show resolved Hide resolved
Co-authored-by: Linus Unnebäck <>
LinusU approved these changes Nov 5, 2021
Copy link

@LinusU LinusU left a comment

Neat 👍

@LinusU LinusU requested a review from jimmywarting Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants