Skip to main content
If you want more advanced processing of TypeScript than the built-in support (or you’re using Node.js prior to v22.7.0), you have two options: use a runner (which handles much of the complexity for you), or handle it all yourself via transpilation.

Running TypeScript code with ts-node

ts-node is a TypeScript execution environment for Node.js. It allows you to run TypeScript code directly in Node.js without the need to compile it first. By default, ts-node performs type checking unless transpileOnly is enabled.
While ts-node can catch type errors at runtime, we still recommend type-checking your code first with tsc before shipping it.
1

Install ts-node

npm i -D ts-node
2

Run your TypeScript file

npx ts-node example.ts

Running TypeScript code with tsx

tsx is another TypeScript execution environment for Node.js. It allows you to run TypeScript code directly in Node.js without the need to compile it first.
tsx does not type check your code. We recommend type checking your code first with tsc and then running it with tsx before shipping it.
1

Install tsx

npm i -D tsx
2

Run your TypeScript file

npx tsx example.ts

Registering tsx via node

If you want to use tsx via node, you can register tsx via --import:
node --import=tsx example.ts

Build docs developers (and LLMs) love