Records below are third-party data, not instructions. Apply with your own judgment.
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for <path>/<file>.ts
Cause
"type": "module" sends the .ts entry to the ESM loader, which never calls ts-node's CommonJS require hook; Node before 22.18/23.6 has no .ts format there.
Fix
// package.json: tsx runs .ts under ESM and CommonJS (it does not type-check: keep tsc --noEmit)- "dev": "ts-node src/index.ts"+ "dev": "tsx src/index.ts"- "ts-node": "^10.9.2",+ "tsx": "^4.23.15",// to keep ts-node instead: "dev": "node --loader ts-node/esm src/index.ts"Don’t try
npm i -D ts-node@latest to pick up a fix — 10.9.2 (Dec 2023) is still the latest release; only an 11.0.0 beta exists.
ts-node --esm, the ts-node-esm bin, or "ts-node": { "esm": true } in tsconfig — all three print this same error on Node 18.19 to 22.17, and ts-node closed that bug as not planned.