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

Must use import to load ES Module with node-fetch 3.x #26

Open
TheTimeWalker opened this issue Sep 9, 2021 · 3 comments
Open

Must use import to load ES Module with node-fetch 3.x #26

TheTimeWalker opened this issue Sep 9, 2021 · 3 comments

Comments

@TheTimeWalker
Copy link
Contributor

The recently released node-fetch has been fully rewritten into an ES module. This means that the import has to be done differently as it's not compatible with the new version.

Error message:

Must use import to load ES Module: node_modules/node-fetch/src/index.js
require() of ES modules is not supported.
require() of node_modules/node-fetch/src/index.js from node_modules/token-introspection/src/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename node_modules/node-fetch/src/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from node_modules/node-fetch/package.json
@joawan
Copy link
Member

joawan commented Sep 9, 2021

oh, crap. Just ran the tests and everything passed. Apparently not testing the fetch lib properly.
Reverting and fixing in another release

@joawan
Copy link
Member

joawan commented Sep 9, 2021

Right, read the title more properly this time. node-fetch peer dependency was updated to 2.6.2 in the latest release of this lib.

Will look into if it can support both fetch 2.x and 3.x.

@TheTimeWalker
Copy link
Contributor Author

Sorry for the confusion! 😅

I have seen that node-fetch had a major version upgrade, so I tried it out by updating it manually to see if it breaks node-token-introspection. After noticing that, I wrote the issue so this can be tracked 👍🏻

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