unjs / rc9

Read/Write config couldn't be easier!
Other
269 stars 5 forks source link

Cannot find module 'node:fs' #85

Closed bigbossx closed 1 year ago

bigbossx commented 1 year ago

Environment

node 14,16,18,20 lts

"nuxt": "~2.14.12"

Reproduction

image image image

Describe the bug

I really want to know why I tried almost every node lts version greater than 14 and still get the same error.

However, it is ridiculous that if I directly create a new file just has console.log(reuqire("node:fs")) and execution, There will be no mistakes.

Is it because nuxt's resolver can't recognize node: prefix instead of node itself? This is a really disgusting question and wasted a lot of my time

Additional context

No response

Logs

No response

bigbossx commented 1 year ago

Another disgusting problem is that I can't override the version of rc9, because it is an internal dependency of nuxt

pi0 commented 1 year ago

Hi, and thanks for sharing the issue. It is super strange one since you are sure Node.js version is 20... If possible would you please sent me a comment in discord (@pi0) so we can check on your system what is going on?

bigbossx commented 1 year ago

@pi0 thanks your quickly reply!

1. My system macos . I use nvm to switch node version. I very sure every node lts version has this issues

image

2. Then I did an experiment to prove that my node environment must support node prefix

image

everything change when nuxt use Resolver , I have to suspect that there is an incompatibility

3. And finally this is my workaround, I have to override rc9 version back to 1.2.2

image

ps: please sent me a comment in discord what is it? what should I do?

pi0 commented 1 year ago

Thanks for sharing more info. I think since you are using Nuxt 2 and it might be using an outdated/incompatible version of telemetry or jiti in the dependencies. Your environment supports it but those deps might not.

Can you check jiti version or somehow share your repository with me? Without reproduction i cannot find out what is going wrong

please sent me a comment in discord

https://discord.com/users/pi0

bigbossx commented 1 year ago

ok! I will try to share you a mini reproduct repository. but not now, may be in this weekend when I have free time

bigbossx commented 1 year ago

@pi0 You are right.

when I use nuxt@2.14.12. one of key is this._require = createRequire(module), and in this case nuxt use esm as module resolver 👉 see source code. but esm seem not support node internal module with prefix. if i use nuxt@2.17.1 or higher version, nuxt remove esm will just use jiti source code, so problem be resolved

I think i should upgrade my nuxt version, to resolve this problem.

btw. I find some issues like this say this is mismatch the compat node version, so I just switch my node version and try again and again, but not working. so I must suggest you should tell other one, it also possible he use outdated/incompatible version like me.

finally, thank you!