ts-node
ts-node is a TypeScript execution engine that runs .ts files on Node.js by type-checking each file and compiling it to JavaScript as it loads. A script or a development server can start straight from TypeScript source, without a separate build step that writes .js files first. Each run follows this path:
Version 10.9.2, released in December 2023, is the latest stable release. ts-node calls the compiler API in the typescript package, which TypeScript 7 no longer includes, so projects pair it with TypeScript 6 or earlier. Node.js 26 can also run many .ts files on its own by stripping the types without checking them, and tsx is another runner for the same job.
Installation and Setup
A project installs ts-node as a dev dependency, together with the TypeScript compiler and the Node.js type definitions:
$ npm install --save-dev ts-node typescript@6 @types/node
ts-node reads its compiler settings from the project’s tsconfig.json file. The tsc --init command creates one with the current recommended options:
$ npx tsc --init
Created a new tsconfig.json
You can learn more at https://aka.ms/tsconfig
Next, confirm the installed version:
$ npx ts-node --version
v10.9.2
Key Features
- Type-checks each file before it runs and stops with a
TSErrorwhen the check fails. - Compiles TypeScript just in time, so a project doesn’t need a build step before it runs.
- Skips type checking with the
--transpileOnlyflag, or-T, for faster startup. - Opens a TypeScript REPL when it runs without a file name.
- Hooks into the
nodecommand itself throughnode --require ts-node/register.
Usage
Say a shop’s cart.ts file declares an Item interface with numeric price and quantity fields, then logs the cart total. Running it through npx uses the project’s local copy of ts-node:
$ npx ts-node cart.ts
Total: 22.5
If one item’s price is the string "5" instead of a number, the type check fails and the file doesn’t run:
$ npx ts-node cart.ts
TSError: ⨯ Unable to compile TypeScript:
cart.ts(7,5): error TS2322: Type 'string' is not assignable to type 'number'.
The --transpileOnly flag skips the check and runs the same file anyway. JavaScript coerces "5" to a number during the multiplication, so the total doesn’t change:
$ npx ts-node --transpileOnly cart.ts
Total: 22.5
An npm script in package.json can call ts-node, so npm start runs the file:
{
"scripts": {
"start": "ts-node cart.ts"
}
}
For every option and the ES module setup, see the ts-node documentation.
Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.
By Leodanis Pozo Ramos • Updated Nov. 6, 2026