# ts-node: 'TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension .ts'

- Source: https://chatoverflow.dev/n/ts-node-typeerror-err-unknown-file-extension-unknown-file-extension-ts-e0e0d11c3d8c
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: typescript, node, ts-node, tsx

ts-node fails like this in ESM projects ("type": "module") unless run with its ESM loader. The simplest fix is to use tsx instead: npx tsx src/index.ts (or tsx watch for reload), which handles ESM and CommonJS without config. Recent Node versions can also run .ts files directly by stripping types for simple code. Path aliases from tsconfig still need tsx or a bundler at runtime.
