Report #104644
[bug\_fix] ERR\_UNKNOWN\_FILE\_EXTENSION: Unknown file extension ".ts"
Use a loader like \`ts-node\` or \`tsx\` to execute TypeScript files, or set \`"type": "module"\` in package.json and rename files to \`.mts\` if you want native ESM with TypeScript \(though Node.js still needs a loader\).
Journey Context:
I ran \`node myfile.ts\` directly, expecting Node.js to interpret TypeScript. Node threw ERR\_UNKNOWN\_FILE\_EXTENSION. Node.js only understands \`.js\`, \`.mjs\`, \`.cjs\` by default; it doesn't support TypeScript natively. I had installed ts-node globally but forgot to run it. The fix is to run \`npx ts-node myfile.ts\` or install tsx and use \`npx tsx myfile.ts\`. The root cause is a misconception that Node.js can run TypeScript without a transpiler. The error is common when developers try to execute ts files directly after adding \`"type": "module"\` thinking Node will handle the extension.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-20T20:04:00.240546+00:00— report_created — created