Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 4 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

tsx

Run TypeScript files without a build step.

Languages, types and runtimesNPM

GitHubWebsite

1. License

“Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction”

Any use is allowed; keep the MIT notice with tsx's files.

github.com/privatenumber/tsx/blob/master/LICENSE

From the package registry and GitHub, checked daily; card checked Nov 11, 2026. Tap a verdict to see its source.How we checkedReport an error

What tsx does

tsx is a free command that runs TypeScript files directly with Node.js, the same way node runs JavaScript. Your assistant can write a script, a small server or a test in TypeScript and run it at once, with no separate build step. It does not check types; that stays a separate step.

What people build with it

Run a one-off TypeScript script

Your assistant writes a script that fills a test database or exports orders to a spreadsheet, and runs it at once with one command.

Restart the app on every save

While you work on a small server or bot, it reruns by itself each time a file changes.

Test TypeScript with Node's runner

Tests written in TypeScript run with Node.js's own test runner, with no extra test framework.

TypeScript config files in your tool

People who use your tool or plugin system write its settings file in TypeScript, and your tool loads it.

A small backend without a build

A small internal app runs from its TypeScript files on the server, if tsx is installed there as a normal package.

Run a local helper for your AI assistant Idea

A small TypeScript helper, such as a local tool server your assistant connects to, starts with one tsx command.

tsx popularity

84 / 100
Gid Score, #45 overall
146M
downloads a week, npm
12.2K
GitHub stars
953
agent projects use it
tsx: downloads per weeknpm, tsx 146,175,969
tsx: GitHub starsprivatenumber/tsx 12,219

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How tsx is used

  • tsx is a dependency in 953 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (19.6% of the 4,867 JavaScript/TypeScript ones), #2 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 3,231; those are left out of every share on this page.
  • The most used alternative in our scan is ts-node (295 projects).
  • Projects that use it most often also use TypeScript (95.3%), Zod (58.2%), dotenv (44.8%).
  • It is more common in projects set up for OpenClaw (23.4%) than for OpenCode (13.1%).

By coding agent

562 projects, 17.1%
413 projects, 13.6%
388 projects, 15.9%
100 projects, 21.1%
81 projects, 17.3%
78 projects, 23.4%
51 projects, 18.3%
45 projects, 13.1%

Often used with

In 95.3% of its projects
In 58.2% of its projects
In 44.8% of its projects
In 51.5% of its projects
In 50.8% of its projects
In 53.4% of its projects
In 45.9% of its projects

tsx in practice

Strengths

Same command line as node

You call tsx the way you call <code>node</code>, and Node CLI flags pass through. The site's example is <code>tsx --env-file=.env ./file.js</code>, which also shows that plain JS files run.

No config file to start

The site says you can run TypeScript "without worrying about configuration" because tsx ships with "modern and sensible defaults".

Load ESM dependencies from CommonJS

The site says CommonJS code can load ESM dependencies without <code>ERR_REQUIRE_ESM</code> "on supported Node.js versions".

tsconfig paths and Watch mode built in

tsx reads <code>tsconfig.json</code> paths. Its Watch mode re-runs your files each time you save them.

Watch out for

ESM importing CommonJS is not smoothed over

The ESM help covers CommonJS loading ESM. The site says Node.js module semantics still apply when an ES module imports CommonJS. For legacy packages with incompatible default exports, it points to the FAQ.

Loader flag depends on Node version

Mehul Kar's post is inconsistent about Node 18. One passage says <code>--loader</code> does not work there but <code>--import</code> does. Another says <code>--import tsx</code> doesn't work in Node 18 and that he just bumped to Node 20. His working setup is pinned to Node v20.11.1 and tsx@4.7.2, and he notes that versions matter more in nascent technology.

Install as a dev dependency and run a file

$ npm install -D tsx
$ npx tsx ./file.ts

More about tsx

Funding
  • GitHub Sponsors: https://github.com/privatenumber
  • 34 GitHub sponsors

See all

Head to head
Packages around it
  • typescript: The language tsx runs
  • zod: Schema validation
  • vitest: Test runner
  • dotenv: Env file loading
  • @modelcontextprotocol: MCP SDK
  • express: Web server framework
More in Languages, types and runtimes

Alternatives

tsx This page

MITGid 84146M/wk

ts-node

Pick ts-node when you want types checked while the code runs, using the TypeScript compiler itself.

MITGid 8162.2M/wk

jiti

Pick jiti when a tool only needs to load TypeScript config files at runtime with no command of its own.

MITGid 67269M/wk

Bun

Pick Bun when you are ready to switch the whole runtime; it runs TypeScript itself and also installs packages.

Compare tsx with another tool

Get started

Tell your AI assistant

“Add tsx as a dev dependency (pin tsx@4.23.15, Node.js 20.6+), run TypeScript scripts with npx tsx ./file.ts (tsx flags before the file, script arguments after), use tsx watch during development, and add a separate "type-check" script with tsc --noEmit.”

  1. Install tsx in your project as a development package.

    npm install -D tsx

    From tsx.hirok.io/installation

  2. Run a TypeScript file where you would run node.

    npx tsx ./script.ts

    From tsx.hirok.io/

  3. Check types separately with the TypeScript compiler.

    npx tsc --noEmit

    From tsx.hirok.io/faq

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## tsx
- Run TypeScript files with `tsx file.ts` wherever you would use `node file.js`. Node CLI flags such as `--env-file=.env` pass through.
- Install it as a project dev dependency (`npm install -D tsx`, `pnpm add -D tsx` or `yarn add -D tsx`).
- Inside `package.json#scripts`, call `tsx` directly without `npx`, for example `"start": "tsx ./file.ts"`.
- For a one-off run without installing, use `npx tsx ./script.ts`.
- Use a maintained Node.js version. The docs say tsx targets all maintained versions, and loading ESM from CommonJS works only "on supported Node.js versions".
- When an ES module imports a CommonJS package, Node.js module semantics still apply. Check the tsx FAQ before working around legacy packages with incompatible default exports.
- Don't run `yarn global add` with Yarn 2. The docs note that Yarn 2 doesn't support global installation.

Mistakes to avoid

Treating "it ran with tsx" as "the types are correct"
Add "type-check" with tsc (noEmit) to package.json scripts and run it in CI or before commits

tsx strips types without checking them; in our run const seats: number = 'three' ran and printed three.

Replacing tsx with plain node file.ts on Node.js 22.18+ or 24 for code with enums or tsconfig paths
Keep tsx for such code, or rewrite it to erasable syntax only (no enums, no namespaces with code, no paths)

Node's built-in type stripping errors on enums; in our run Node.js 24.22.2 failed with ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX: TypeScript enum is not supported in strip-only mode.

npx tsx ./file.ts --tsconfig ./tsconfig.custom.json (tsx flags after the file)
npx tsx --tsconfig ./tsconfig.custom.json ./file.ts --name Ada

Everything after the file path goes to your script, not to tsx or Node.js.

Top-level await in a .ts file of a package without "type" "module"
Rename the file to .mts or set "type" "module" in package.json; or wrap the code in an async function

Top-level await needs ES module mode, and the import syntax alone does not choose it.

Installing tsx with -D and starting the production server with tsx after npm ci --omit=dev
Install tsx as a normal dependency for that server, or build to JavaScript and run node on the output

Production installs that skip development packages will not have tsx.

Questions

Does it check my types?

No. Run tsc --noEmit separately; in our run a file assigning a word to a number still ran.

Node.js can run .ts files now. Do I still need tsx?

Node.js only strips types; enums, namespaces with code and tsconfig paths fail there. In our run Node.js 24 stopped at an enum that tsx ran.

Can I use it in production?

Yes, if tsx is installed as a normal package there; the other option is to build JavaScript first and run that.

How is it different from ts-node?

tsx uses esbuild and needs no TypeScript compiler to run code; ts-node uses the compiler and can check types while it runs.

Can I use it in a paid product?

Yes. tsx is under the MIT license.