Weird interaction between CJS and ESM for JSON modules, when using yarn
Author: A5rocksCreated May 20, 2026Updated May 21, 2026
Labelsbugpending triage
Acknowledgements
- I read the documentation and searched existing issues to avoid duplicates
- I understand this is a bug tracker and anything other than a proven bug will be closed
- I understand this is a free project and relies on community contributions
- I read and understood the Contribution guide
Minimal reproduction URL
I provided the exact source below; I don't have a StackBlitz to upload it there.
Problem & expected behavior (under 200 words)
Make sure to use yarn.
package.lock:
{
"name": "example",
"version": "1.0.0",
"type": "module",
"packageManager": "[email protected]",
"dependencies": {
"http-errors": "^2.0.1"
},
"devDependencies": {
"@types/http-errors": "^2",
"tsx": "^4.22.3"
}
}src/index.ts:
import { errors } from "./errors.js";
errors;src/errors.ts:
import { isHttpError } from "http-errors";
export const errors = () => {
isHttpError;
};Run:
yarn installyarn tsx src/index.ts
Bugs are expected to be fixed by those affected by it
- I'm interested in working on this issue
Compensating engineering work will speed up resolution and support the project
- I'm willing to offer $10 for financial support
Source: privatenumber/tsx