🔧
Build Tool8M+/wkMIT

tsx

tsx is a TypeScript execute tool that lets you run TypeScript files directly in Node.js without a compilation step, using esbuild for near-instant transformatio

Installation

npm
npm install -D tsx
yarn
yarn add -D tsx
pnpm
pnpm add -D tsx

Import

ESM
// Used as CLI: tsx script.ts

Quick Example

usage
// Run TypeScript directly:
// npx tsx src/script.ts

// Watch mode:
// npx tsx watch src/server.ts

// With Node.js flags:
// node --import tsx src/app.ts

About tsx

tsx is a TypeScript execute tool that lets you run TypeScript files directly in Node.js without a compilation step, using esbuild for near-instant transformation. tsx serves as a modern replacement for ts-node, providing significantly faster startup times because esbuild compiles TypeScript to JavaScript orders of magnitude faster than the TypeScript compiler. tsx supports ESM and CommonJS modules, path aliases from tsconfig.json, watch mode that re-runs your script on file changes, and works with Node.js's built-in test runner and --inspect flag for debugging. The tool operates by registering itself as a module loader that intercepts .ts, .tsx, .mts, and .cts file imports and transforms them on the fly using esbuild. tsx does not perform type checking — it only strips types and transforms syntax, matching esbuild's compilation model where type errors are caught separately by tsc or IDE integration. This separation of concerns (fast execution vs. thorough type checking) follows the modern TypeScript development pattern. tsx is particularly useful for running scripts, development servers, database migrations, and seed files written in TypeScript without maintaining a separate build step.

Quick Facts

Packagetsx
CategoryBuild Tool
Weekly Downloads8M+
LicenseMIT
Installnpm install -D tsx

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.