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

Upgrading 3.0.0 to 3.1.0 is a breaking change, major not minor update. #1391

Closed
basickarl opened this issue Nov 18, 2021 · 4 comments
Closed
Labels

Comments

@basickarl
Copy link

basickarl commented Nov 18, 2021

Just for your information when upgrading to 3.1.0 from 3.0.0 I got a breaking change in my build system, hence yous should of bumped it to 4.0.0.

v.3.0.0
working

v3.1.0

    Cannot find module 'node:http' from 'index.js'

    Require stack:
      node_modules/node-fetch/src/index.js
      test/contract/consumer-test.js

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:299:11)
      at Object.<anonymous> (node_modules/node-fetch/src/index.js:9:1)

As you can see from the stacktrace, we are importing node-fetch into a test in the jest framework (jest version 25.1.0).

@basickarl basickarl added the bug label Nov 18, 2021
@jimmywarting
Copy link
Collaborator

We did not account for ppl to use build steps. that is why it was not a major change.

v3 was released with a breaking change of requiring node v12.20 at which point node: prefixes is supported in esm but not in commonjs.

The recommended way to load node-fetch@3 is via import fetch from 'node-fetch'
even if you are using commonjs then it should use: import('node-fetch').then(...)
Read more here of how to prevent bundlers to rewrite it: #1279 (comment)
Another recommendation is that you change the target to output esm

As of now, i'm closing this as a duplicate of #1367 (comment)

@jimmywarting
Copy link
Collaborator

jimmywarting commented Nov 18, 2021

@basickarl, just for curiosity... what build tool where you using that generaded cjs? (other then jest)

@jimmywarting
Copy link
Collaborator

jimmywarting commented Nov 18, 2021

Also in the other issue i linked to, they are blocked from using a newer node version by aws
aws use node 14.17
and node: prefix was added for commonjs in NodeJS v14.18

so another quick solution on your part could simply be to update the node version.

@basickarl
Copy link
Author

@basickarl, just for curiosity... what build tool where you using?

Good old Jest! (Jest does transpiling behind the scenes, we do have config files which Jest read, but nothing major though.).

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

No branches or pull requests

2 participants