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?]: Error code for dir import in PnP-ESM #6284

Open
1 task
KcZer0 opened this issue May 9, 2024 · 0 comments
Open
1 task

[Bug?]: Error code for dir import in PnP-ESM #6284

KcZer0 opened this issue May 9, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@KcZer0
Copy link

KcZer0 commented May 9, 2024

Self-service

  • I'd be willing to implement a fix

Describe the bug

Error code when importing directory in Node.js is ERR_UNSUPPORTED_DIR_IMPORT.
But in Yarn PnP+ESM it's ERR_MODULE_NOT_FOUND.

This is causing import error for custom loader as in privatenumber/tsx#439

To reproduce

package.json

{
  "type": "module"
}

dir/index.js

export {};

index.js

try {
  const a = await import('./dir');
  console.log(a);
} catch ({ code }) {
  console.log(code); 
  // node: `ERR_UNSUPPORTED_DIR_IMPORT`
  // yarn-pnp-esm: `ERR_MODULE_NOT_FOUND`
}

Environment

System:
  OS: Windows 11 10.0.22631
  CPU: (16) x64 AMD Ryzen 7 6800H with Radeon Graphics         
Binaries:
  Node: 20.11.0 - D:\Temp\AppData\xfs-e4b9d728\node.CMD
  Yarn: 4.2.2 - D:\Temp\AppData\xfs-e4b9d728\yarn.CMD
  npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD

Additional context

No response

@KcZer0 KcZer0 added the bug Something isn't working label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant