Native TypeScript support in Node.js fits small scripts and project utilities that already use JavaScript-compatible runtime syntax. The runtime removes erasable type annotations while loading the file, so a simple .ts file can run with node without a separate transpile step.
The built-in loader does not run the TypeScript compiler. It ignores tsconfig.json for path aliases and downlevel transforms, keeps normal Node.js module rules, and requires file extensions such as ./helper.ts in import specifiers.
Use native execution when the file stays inside the type-stripping subset. Keep a separate type-checking or build step for projects that use enums, decorators, parameter properties, TSX, path aliases, or other TypeScript features that need generated JavaScript.
Steps to run TypeScript directly with Node.js:
- Check that Node.js has stable built-in type stripping.
$ node --version v24.18.0
Use Node.js 24.12 LTS or newer for stable type stripping. Earlier supported releases had experimental behavior or warnings.
- Create a TypeScript file that only uses erasable type syntax.
- greeter.ts
type User = { name: string; active: boolean; }; function describe(user: User): string { return `${user.name} is ${user.active ? "active" : "inactive"}`; } const account: User = { name: "Mira", active: true }; console.log(describe(account));
Type aliases, interfaces, and typed parameters are removed before execution. Node.js still runs the remaining JavaScript without type-checking it.
- Run the TypeScript file with node.
$ node greeter.ts Mira is active
For multi-file code, include the .ts, .mts, or .cts extension in import specifiers. Node.js does not resolve ./helper to ./helper.ts.
- Create a file that uses syntax requiring TypeScript code generation.
- unsupported.ts
enum Status { Ready = "ready", } console.log(Status.Ready);
Native type stripping rejects enums, parameter properties, runtime namespaces, import aliases, decorators, and TSX. Use tsc, tsx, or another transpiling runner when the project needs those features.
- Run the unsupported file to confirm the native execution boundary.
$ node unsupported.ts /home/developer/native-ts-demo/unsupported.ts:1 > enum Status { Ready = "ready", > } SyntaxError [ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX]: TypeScript enum is not supported in strip-only mode ##### snipped ##### - Remove the sample files after testing.
$ rm greeter.ts unsupported.ts
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.