jsdom-worker icon indicating copy to clipboard operation
jsdom-worker copied to clipboard

node-fetch 3.x broken in jest

Open yunnysunny opened this issue 3 years ago • 2 comments

node-fetch use esm with 3.x, which not support with jest now, see the issue here https://github.com/node-fetch/node-fetch/discussions/1503 . So, can we roll back the node-fetch to 2.6 to resolve the problem?

yunnysunny avatar Nov 11 '22 07:11 yunnysunny

There's nothing for the lib to correct, the peer dep on node-fetch allows any version to satisfy it:

https://github.com/developit/jsdom-worker/blob/aaf2874b87b4ab6d6d3113cd816e510d447331d3/package.json#L73-L75

Use whichever version you'd like. It's up to you.

rschristian avatar Nov 26 '22 14:11 rschristian

I think I faced the same issue trying to use this library with node 16, which was working fine until I tried to update the dependencies I have in my project.

Before starting, this is what I have:

[email protected]
v16.17.1

Besides that, I was using nodejs 16 since I started the project, but just now I realize I needed to update its dependencies, in doing so through npm update this is the error I get:

image

I think this error is possibly related to this issue that @yunnysunny reported as I started to dive in a bit and found that the issue is in the node-fetch import:

image

This issue seems to be related to the node version and also to version 3.3+ from node-fetch. I think this issue is related.

The way I fixed the issue temporarily was to install the lib node-fetch 3.0.0 in my project as mentioned by @rschristian, but it has some security issues reported.

I think that the question going forward here is if it is possible to support newer versions of node-fetch here.

marabesi avatar Dec 18 '22 11:12 marabesi