[Bug?]: Error code for dir import in PnP-ESM
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 8.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
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 https://github.com/privatenumber/tsx/issues/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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the reproduction using package.json, dir/index.js, and index.js with Yarn PnP and Node.js, then inspect the PnP ESM resolution path for directory imports. Compare the resulting error code with Node.js, including the custom-loader context from the linked report; done means the behavior is understood and the reported error code is corrected or its incompatibility is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100