unjs / jiti

Runtime Typescript and ESM support for Node.js
MIT License
1.49k stars 52 forks source link

Error "Cannot find module 'node:url '" after upgrading to jiti 1.21.3 in Node 14.17.6 environment #243

Closed siLiang220 closed 1 month ago

siLiang220 commented 1 month ago

Environment

Reproduction

  1. Upgrade jiti to version 1.21.3 in a Node 14.17.6 environment

Describe the bug

I upgraded jiti to version 1.21.3 in a Node 14.17.6 environment, but encountered the above error. From my understanding, this may be due to some changes in jiti version 1.21.3, possibly related to compatibility with Node versions.

Additional context

No response

Logs

No response

danielroe commented 1 month ago

Would you be able to provide a minimal reproduction? 🙏

danielroe commented 1 month ago

You might need to upgrade to Node 14.18.0+

https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_node_imports

siLiang220 commented 1 month ago

Thank you for your response. I have rolled back to using version 1.21.0 for now. Thank you for the suggestion regarding upgrading Node. I will consider upgrading to Node 14.18.0+ if necessary.

pi0 commented 1 month ago

I have added a relavant refactor (https://github.com/unjs/jiti/commit/5d877de3fc24312c870c55f7a7445cb250ac9949) but checking dist (we have another check for it for #109), and also locally with latest Node.js 14.x, same as @danielroe i could not reproduce...

I would suggest to upgrade to a supported Node.js version like 20 if you can.