Luke Oliff.

TIL: Running TypeScript Directly With ts-node

·TIL·1 min read·Luke Oliff

TypeScript needs to compile before it runs. ts-node skips the compile step and runs it directly.

ts-node sdk-example.ts

Compiles the file in memory and executes it. Output appears immediately. No outDir, no tsc –watch, no incremental build.

ts-node --transpile-only sdk-example.ts

Skip type checking for faster execution. Use this during development when you know the types are correct and just want to see output.

ts-node --swc sdk-example.ts

Use the SWC compiler instead of the default TypeScript compiler. SWC is written in Rust and compiles significantly faster.

Does ts-node work with ES modules?

Yes. Set tsconfig.json to use ESNext module resolution and pass –esm to ts-node.

How do I install ts-node?

npm install -g ts-node

Or add it as a dev dependency and run it with npx ts-node.