ts-node
TypeScript execution environment for Node.js with source map support.
3. Used by agents' projects
Dependency in 295 public GitHub projects set up for AI coding agents that we scanned (4.7%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
nodejs.org/llms.txtFrom the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What ts-node does
ts-node hooks Node's module loading so <code>.ts</code> files run on Node.js with no build step, and most of its options can live in a <code>"ts-node"</code> block in <code>tsconfig.json</code>, so they apply even where you cannot pass flags.
ts-node popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How ts-node is used
- ts-node is a dependency in 295 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (6.1% of the 4,867 JavaScript/TypeScript ones), #3 of 70 in languages, types and runtimes.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,342; those are left out of every share on this page.
- The most used alternative in our scan is tsx (953 projects).
- Projects that use it most often also use Jest (44.4%), TypeScript (95.9%), dotenv (46.1%).
- It is more common in projects set up for Devin Desktop (8.6%) than for Claude Code (4.2%).
By coding agent
Often used with
ts-node in practice
Strengths
Most options go in a <code>"ts-node"</code> object in <code>tsconfig.json</code>, using their camelCase names. The maintainers recommend this because it still works under <code>node --require ts-node/register</code> and in shebang scripts.
Setting <code>NODE_OPTIONS</code> to <code>-r ts-node/register</code> or <code>--loader ts-node/esm</code> installs the hooks in Node processes that receive the variable. The README says this enables ts-node in other node tools, child processes and worker threads "in many cases".
<code>--transpileOnly</code> (<code>-T</code>) switches to TypeScript's faster <code>transpileModule</code>. It defaults to <code>false</code>, and it can also be set with the <code>TS_NODE_TRANSPILE_ONLY</code> environment variable.
With no <code>tsconfig.json</code> on disk, the README says ts-node uses "the newest recommended defaults" from @tsconfig/bases that are compatible with your <code>node</code> and <code>typescript</code> versions. Older TypeScript versions get an older default configuration.
Watch out for
The README says ts-node CLI flags must come before the entrypoint script, as in <code>ts-node --project tsconfig-dev.json say-hello.ts</code>.
Flags such as <code>--trace-deprecation</code> cannot be passed to the ts-node binary or set in <code>tsconfig.json</code>. The maintainers recommend <code>NODE_OPTIONS</code>. The other option is to call <code>node</code> directly with <code>-r ts-node/register</code>.
The short flag for the tsconfig path is uppercase <code>-P</code>. The docs point out that this differs from <code>tsc</code>. In ts-node, lowercase <code>-p</code> prints the result of <code>--eval</code>.
Starting tsconfig.json with a ts-node block
{
// This is an alias to @tsconfig/node16: https://github.com/tsconfig/bases
"extends": "ts-node/node16/tsconfig.json",
// Most ts-node options can be specified here using their programmatic names.
"ts-node": {
// It is faster to skip typechecking.
// Remove if you want ts-node to do typechecking.
"transpileOnly": true,
"files": true,
"compilerOptions": {
// compilerOptions specified here will override those declared below,
// but *only* in ts-node. Useful if you want ts-node and tsc to use
// different options with a single tsconfig.json.
}
},
"compilerOptions": {
// typescript options here
}
}More about ts-node
Funding
- GitHub Sponsors: https://github.com/blakeembrey
- GitHub Sponsors: https://github.com/cspotcode
- 10 GitHub sponsors
Head to head
- tsx vs ts-node used together in 89 projects
- ts-node vs jiti used together in 22 projects
Packages around it
- typescript: TypeScript compiler
- dotenv: Env file loader
- @solana/web3.js: Solana JS client
- jest: Test runner
- prettier: Code formatter
- @solana/spl-token: Solana token client
More in Languages, types and runtimes
Alternatives
ts-node This page
Node.js enhanced with esbuild to run TypeScript and ESM files.
Runtime TypeScript and ESM support for Node.js without build steps.
Get started
Install it.
npm install ts-nodeRules for your agent
## ts-node
- Install locally as dev dependencies: `npm install -D typescript` and `npm install -D ts-node`. Add `tslib` and `@types/node` if the configuration needs them.
- Put ts-node options in a `"ts-node"` object in `tsconfig.json`, using camelCase names, rather than in CLI flags or shebangs.
- When using CLI flags, place them before the entrypoint script, for example `ts-node --project tsconfig-dev.json say-hello.ts`.
- Use uppercase `-P` (or `--project`) for the tsconfig path. Lowercase `-p` means print.
- Pass Node's own flags through `NODE_OPTIONS` or directly to `node` with `-r ts-node/register`. Do not put them in `tsconfig.json`.
- For native ESM, use `--esm`, `ts-node-esm`, or `node --loader ts-node/esm`.
- When config behaves unexpectedly, run `ts-node --showConfig` and `ts-node -vv` before changing settings.