Skip to content

Frequently Asked Questions

How can I do __ in tsx?

It's important to remember that tsx is a Node.js enhancement—it's still Node underneath.

That said, often times you might want to ask and lookup the following instead:

  • "How can I do __ in Node.js?"
  • "How can I do __ in TypeScript?"

Who uses tsx?

tsx currently gets and is used by many projects.

Here are some notable ones I've found via GitHub Search:



How does tsx compare to ts-node?

tsx and ts-node are both designed for executing TypeScript in Node.js, but offer different approaches to suit user preferences.

  • Simple installation

    tsx is offered as a single binary without peer dependencies, and can be used without installation (just run npx tsx ./script.ts). In comparison, ts-node requires installing TypeScript or SWC as peer dependencies.

  • Zero configuration

    tsx just works. It doesn't require initial setup or a tsconfig.json file, and doesn't get in the way of running your code. This is especially important for beginners getting into TypeScript!

  • Sensible defaults

    tsx employs sensible defaults based on file imports and the Node.js version, removing the need for certain tsconfig.json settings (that are designed for compilation rather than runtime). In comparison, ts-node relies on TypeScript's defaults (e.g. ES3 target), which may be outdated.

  • Module adaptability

    tsx automatically adapts between CommonJS and ESM modules, even supporting require() of ESM modules, facilitating a smoother transition as the Node.js ecosystem evolves.

  • Enhancements

    tsx gracefully handles new JS & TS syntax and features based on the Node.js version. It also supports tsconfig.json paths out of the box.

  • Speed

    tsx utilizes esbuild for rapid TypeScript compilation. In comparison, ts-node uses the TypeScript compiler by default. Because tsx doesn't type check, it's similar to ts-node --esm --swc (which uses the SWC compiler).

  • Watcher

    As a DX bonus, tsx also comes with Watch mode to help you iterate faster!

For a detailed technical comparison, you can refer to this exhaustive comparison between tsx, ts-node, and other runtimes.

Can/should it be used in production?

At the end of the day, this is something you'll have to evaluate yourself against your production needs and risk tolerance.

Some factors you might want to consider are:

  • tsx is Node.js enhanced, so you can expect similar levels of stability.

  • tsx uses esbuild to transform TypeScript and ESM, and esbuild hasn't reached a stable release yet.

Some questions you might want to ask yourself are:

  • What are the benefits vs costs of using tsx in production?

    • Are there performance costs?
  • Does tsx run my code expectedly? Are there different environments and tools being used between dev and production?

  • Can I rely on this open source project and the maintainers?

Can't find your question?

Try searching or asking in GitHub Discussions!