tsx

A drop-in replacement for the node CLI that runs TypeScript and ESM files instantly, powered by esbuild.

Tool
npm
v4.23.15
12,162 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
88 /100 Excellent
Development Activity 96
Maintenance 100
Community 60
Maturity 56
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
85 /100 Excellent
Architecture 85
Code Quality 88
Innovation 78
Learning Curve 90

tsx (TypeScript Execute) is a Node.js enhancement that lets you run TypeScript files the same way you’d run a plain JavaScript file with node — no build step, no ts-node configuration, no separate loader setup. Under the hood it swaps in esbuild to transform TypeScript and modern JavaScript syntax on the fly, then re-spawns node with the appropriate CommonJS or ESM hooks wired in via —require/—import.

Beyond straight execution, tsx smooths over the CJS/ESM split that has fragmented the Node.js ecosystem since ES Modules landed: it lets CommonJS code require() ESM dependencies without hitting ERR_REQUIRE_ESM, resolves tsconfig.json path aliases at runtime, and honors Node’s own CLI flags so it behaves exactly like node in every other respect. A built-in watch mode reruns your script on file changes for fast iteration, and a Developer API (tsImport, register hooks, an entry-point import) lets other tools and libraries load TypeScript files programmatically without tsx owning the whole process.

What You Get

  • A tsx CLI that behaves exactly like node — same flags, same argument positioning — but accepts .ts/.tsx/.mts/.cts files directly
  • Automatic CJS/ESM interop so CommonJS code can require() ESM-only packages without ERR_REQUIRE_ESM
  • esbuild-powered on-the-fly transforms with a filesystem cache so repeat runs skip re-compilation
  • tsconfig.json path-alias resolution baked into both the CJS resolver and the ESM loader hook
  • Built-in watch mode (tsx watch) that restarts your script on file changes, with include/exclude globs and screen clearing
  • A TypeScript-aware REPL and a patched Node test runner integration (tsx --test) for .ts test files
  • A Developer API (register, tsImport, entry-point import) for embedding TypeScript loading into other tools without invoking the tsx CLI

Common Use Cases

  • Running one-off TypeScript scripts or CLI tools during local development without a compile step
  • Powering the dev/start script for Node.js backends written in TypeScript, in place of ts-node
  • Loading TypeScript configuration files (e.g. build tool configs) from within another program via the tsImport API
  • Executing TypeScript test files directly with Node’s built-in test runner via tsx --test
  • Iterating on scripts with tsx watch so file saves automatically re-run the process

Under The Hood

Architecture tsx separates a thin CLI entry point (src/cli.ts) from the actual execution mechanism (src/run.ts), which re-spawns a child node process with --require flags for a preflight script and a REPL patch, plus --import/--loader pointing at a loader that wires in the CJS and ESM hooks. Those hooks live in clearly separated src/cjs and src/esm/hook directories that plug into Node’s own module-resolution APIs rather than monkey-patching internals. Watch mode (src/watch) reuses the same spawn-based run() function behind a file watcher, relaying OS signals between parent and child over an IPC socket — so the spawn/hook wiring in run.ts is a shared foundation that watch mode, the REPL, and the Developer API entry points all depend on.

Tech Stack Written in TypeScript targeting es2022 with strict compiler settings, and transformed by esbuild both for its own build (via pkgroll) and as its runtime execution engine. Uses cleye for CLI flag parsing, chokidar for watch-mode file watching, get-tsconfig for tsconfig path-alias resolution, cross-spawn to launch the child node process, and kolorist for terminal output styling. Ships dual CJS/ESM builds through a detailed package.json exports map — there’s no database or web framework involved, since this is a Node.js runtime-augmentation tool distributed purely through npm.

Code Quality An extensive test suite under tests/specs covers CLI behavior, watch mode, the REPL, module loaders, tsconfig resolution, CJS/ESM interop contracts, and even PTY-based shell interaction, run through the manten test runner across multiple Node.js versions with a CI timeout guard to catch stuck runs. Strict TypeScript settings (strict mode, noImplicitOverride) are paired with lintroll for linting, and the codebase consistently separates CJS and ESM concerns into distinct source directories rather than mixing them.

What Makes It Unique tsx treats CommonJS/ESM interop as a first-class problem rather than an afterthought — resolving package.json exports subpaths, letting require() tolerate ESM-only dependencies, and doing so through Node’s official loader hook APIs instead of patching internals directly. That’s a meaningful point of differentiation from older TypeScript-execution tools that predate stable loader hooks, though the core idea of transforming TypeScript through esbuild at require/import time is a pattern this project shares with several comparable tools.

Used by 177 apps in this directory

TypeScript
89%
Other

Hexclave

Authentication · Developer Tools

6,862

The open-source user infrastructure platform — authentication, teams, payments, emails, analytics, and more on a single unified user model.

View details
87
Repo Health
80
Technical
66
Dependency
Built with
TypeScript 89%
Updated 1 weeks ago
Java
46%
Other

Stirling PDF

Digital Signiture · Productivity

93,148

The open-source PDF platform you can run anywhere — edit, convert, sign, and automate PDFs without sending files to external servers.

View details
92
Repo Health
86
Technical
71
Dependency
Built with
Java 46%
TypeScript 45%
Updated 1 weeks ago
Go
65%
GPL 3.0

Stormkit

Devops · Hosting Control Panel

262

Self-hostable platform for deploying and hosting modern web apps with automated CI/CD, custom domains, and a built-in serverless runtime — a true open-source alternative to Vercel and Netlify.

View details
79
Repo Health
79
Technical
67
Dependency
Built with
Go 65%
TypeScript 32%
Updated 1 weeks ago
TypeScript
88%
Other

strapi

CMS

73,243

Open-source headless CMS that auto-generates REST and GraphQL APIs from your content models, with a fully customizable admin panel you control.

View details
93
Repo Health
84
Technical
66
Dependency
Built with
TypeScript 88%
JavaScript 12%
Updated 1 weeks ago
TypeScript
72%
Apache 2.0

Supabase

Authentication · Databases · Developer Tools

110,828

The open-source Postgres development platform that replaces Firebase with authentication, real-time APIs, edge functions, storage, and vector embeddings — all built on PostgreSQL.

View details
90
Repo Health
91
Technical
62
Dependency
Built with
TypeScript 72%
MDX 26%
Updated 1 weeks ago
TypeScript
54%
MIT

Superagent

AI Agents · Security

6,757

An open-source SDK that blocks prompt injections, redacts PII and secrets, scans repositories for AI-targeted attacks, and red-teams production agents.

View details
69
Repo Health
66
Technical
74
Dependency
Built with
TypeScript 54%
Python 43%
Updated 1 months ago
TypeScript
96%
Other

superglue

AI Agents · Data Engineering · Developer Tools

2,063

superglue is an AI-agent-driven integration engine that turns plain-English descriptions of enterprise systems into production-grade API tools, ERP/CRM connectors, and data pipelines — self-hosted or cloud, Y Combinator-backed (W25).

View details
49
Repo Health
79
Technical
67
Dependency
Built with
TypeScript 96%
Updated 1 months ago
TypeScript
98%
Apache 2.0

superlog

AI Agents · Monitoring

1,455

Open-source agentic observability that ingests OpenTelemetry signals, groups them into incidents, and deploys AI agents to investigate and fix your production bugs automatically.

View details
64
Repo Health
73
Technical
73
Dependency
Built with
TypeScript 98%
Updated 2 weeks ago
TypeScript
85%
Apache 2.0

superset

AI Code Assistants · AI Development

14,690

Orchestrate an army of AI coding agents—Claude Code, Codex, Gemini CLI, and more—running simultaneously in isolated git worktrees from a single Electron desktop app.

View details
86
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 85%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers