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

🐛 BUG: could not resolve node:* when upgrading to node-fetch v3 #1739

Closed
kckeiks opened this issue Aug 26, 2022 · 2 comments
Closed

🐛 BUG: could not resolve node:* when upgrading to node-fetch v3 #1739

kckeiks opened this issue Aug 26, 2022 · 2 comments
Labels
bug Something that isn't working

Comments

@kckeiks
Copy link

kckeiks commented Aug 26, 2022

What version of Wrangler are you using?

2.0.26

What operating system are you using?

Linux

Describe the Bug

I started a new project from the Workers tutorial. It's just a simple program that uses node-fetch to make a GET request to an API. Everything was fine until I upgraded node-fetch from V2 to V3 to use a particular feature. When I run wrangler dev, I get this error:

  node_modules/fetch-blob/from.js:1:59: ERROR: Could not resolve "node:fs"
  node_modules/fetch-blob/from.js:2:25: ERROR: Could not resolve "node:path"
  node_modules/node-fetch/src/body.js:8:34: ERROR: Could not resolve "node:stream"
  node_modules/node-fetch/src/body.js:9:42: ERROR: Could not resolve "node:util"
  node_modules/node-fetch/src/body.js:10:21: ERROR: Could not resolve "node:buffer"

Unfortunately, it's not an option for me to use V2 or builtin fetch.
node-fetch/node-fetch#1367 might be related?
Thanks in advance.

@kckeiks kckeiks added the bug Something that isn't working label Aug 26, 2022
@isaac-mcfadyen
Copy link
Contributor

Can I ask why it's not possible for you to use the Workers built-in fetch? It's almost identical in all respects.

node-fetch is almost identical but uses a lot of Node libraries that Workers don't include because Workers are not Node. I'd strongly encourage you to not use node-fetch in Workers because even if you managed to (somehow) polyfill the missing dependencies there's really not much difference between node-fetch and Workers' fetch.

@kckeiks
Copy link
Author

kckeiks commented Aug 28, 2022

Can I ask why it's not possible for you to use the Workers built-in fetch? It's almost identical in all respects.

Initially I was using the builtin fetch but I needed the insecureHTTPParser option to experiment with a particular API. AFAIK neither node-fetch V2 nor the builtin fetch support it.

I'd strongly encourage you to not use node-fetch in Workers because even if you managed to (somehow) polyfill the missing dependencies there's really not much difference between node-fetch and Workers' fetch.

Good to know. Thanks.

@JacobMGEvans JacobMGEvans moved this to Untriaged in workers-sdk Aug 29, 2022
@rozenmd rozenmd closed this as completed Aug 30, 2022
Repository owner moved this from Untriaged to Done in workers-sdk Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
None yet
Development

No branches or pull requests

3 participants