
ts-node
Runs TypeScript files directly in Node.js, with a REPL, without a separate build step.
- Stars
- 13.1k
- Forks
- 548
- Licence
- MIT
- Language
- TypeScript
- Last update
- 2.3 years ago
- Type
- Dev tool
No commits in over a year — check for forks or alternatives before adopting.
What it is
ts-node lets you run TypeScript code directly on Node.js. It compiles TypeScript to JavaScript on the fly as files load, so you do not need a separate precompile step to try a script. It also provides an interactive TypeScript REPL.
- Run a TypeScript script with `ts-node script.ts`
- Start an interactive TypeScript REPL by running `ts-node` with no arguments
- Execute a one-line TypeScript snippet with `ts-node -e`
- Use it with test runners such as Mocha or AVA, per the recipes section
Great for
- Developers running TypeScript scripts or quick experiments locally
- People who want a TypeScript REPL inside Node.js
- Projects that use tsconfig.json and want the same settings when running scripts
- Teams integrating TypeScript execution with test runners or CLI tools
Not ideal for
- Production servers that should run precompiled JavaScript; the README notes ts-node is compatible with pre-compilation but does not present on-the-fly compilation as the production path
- Beginners who have not yet set up Node.js and npm, since installation and configuration involve several concepts
- Projects needing a non-Node runtime, because it is specific to Node.js
How to get it
- 1
Install with a package manager
You'll need: Node.js · npm
Install locally in your project
npm install -D typescriptInstall ts-node locally
npm install -D ts-node - 2
Run it
- Install TypeScript and ts-node locally with npm
- Create a file named script.ts containing console.log("Hello, world!")
- Run it with `ts-node script.ts`
- Or run `ts-node` with no arguments to open the REPL
- 3
Get the most out of it
- Put options in tsconfig.json rather than the command line, which the README recommends for portability
- Use `transpileOnly` to speed up execution when typechecking is not needed, per the Performance section
- Use the shebang `#!/usr/bin/env -S ts-node` with care, since passing options in it depends on the env version
- Integrate with test runners via the README recipes for Mocha, AVA, and others
Downloads
Strengths
- Stack traces map back to the original TypeScript source through sourcemaps
- Reads tsconfig.json automatically
- Supports native ESM loading and optional typechecking
Trade-offs
- Typechecking adds overhead, and the README includes a Performance section on skipping it
- Module loading and ESM behavior can require configuration, and the README has a troubleshooting section for common errors such as ERR_REQUIRE_ESM
- The README is truncated here, so some details of options and limits could not be verified
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| ts-node (this) | 13.1k | Dev tool | intermediate | 2.3 years ago | Developers running TypeScript scripts or quick experiments locally |
| tsx | 12.2k | CLI | beginner | 1 months ago | Developers who already use Node.js and want to run TypeScript scripts quickly |
| deno | 109k | App | beginner | 8 days ago | Developers who want to run TypeScript without a separate build setup |
| distributions | 13.9k | Dev tool | intermediate | 8 days ago | Linux users who want a Node.js version installed through their system package manager |
| ts-pattern | 15.2k | Library | beginner | 23 days ago | TypeScript developers who write many if/else or switch branches over tagged unions |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.