tsx README

The project's README from github.com/privatenumber/tsx. As one markdown file: README.md.


tsx

TypeScript Execute (tsx): The easiest way to run TypeScript in Node.js

Documentation    |    Getting started →


Already a sponsor? Join the discussion in the Development repo!

Sponsors

tsx (privatenumber/tsx)

watch
Searching Database…

12.2K ·GitHub
What is this?tsx (TypeScript Execute) is a CLI that lets you run TypeScript and JSX/TSX files directly in Node.js, transpiling them on the fly with esbuild instead of requiring a separate compile step.
Do I need to compile my TypeScript first, or does tsx run it directly?tsx runs .ts/.tsx (and .js/.jsx) files directly in place of the `node` command — it transpiles source in memory via esbuild before execution, so there's no build step to manage.
How do I run a TypeScript file with it?Use it ad hoc with `npx tsx file.ts`, or add it as a devDependency (`npm install --save-dev tsx`) and invoke `tsx` wherever you'd normally type `node`.
What does it need under the hood?It requires Node.js 18 or newer and bundles esbuild as its only runtime dependency, so there's no extra tsconfig setup required to get going.
Does tsx check my TypeScript types?No — since it relies on esbuild for fast transpilation rather than the full TypeScript compiler, tsx does not perform type checking, so type errors won't stop your code from running.
How is tsx different from ts-node?tsx is built on esbuild instead of the official TypeScript compiler used by ts-node, which makes startup and execution much faster at the cost of skipping type checking.
Can I use it for auto-restarting during development?Yes, `tsx watch file.ts` re-runs your script automatically whenever a dependency changes, similar to nodemon but with built-in TypeScript/JSX support.
Can I use it without changing my run command?Yes, tsx can also act as a Node.js loader hook (e.g. `node --import tsx script.ts`), adding TypeScript support to an existing Node process instead of replacing the `node` binary.
What are similar projects?chokidar, nodemon, scriptc, ava, rspack, bun, esbuild, svgr
Size
3 MB
Stars
12.2K
Age
4y
Commits · 90 Days