Skip to content

Frequently asked questions ​

Find answers about running TypeScript, module imports, and deployment. For installation and a first script, start with Getting started.

How can I do ______ in tsx? ​

tsx runs your program in Node.js and transforms TypeScript as files load. The right reference depends on which part of that workflow you need:

If you are unsure which layer is involved, include the command, error, and a small example when asking for help.

Why does my code run even though it has type errors? ​

tsx transforms TypeScript without checking types, so a type error alone does not stop execution. With TypeScript installed and your project's tsconfig.json configured, run npx tsc --noEmit from the project directory to check types without writing JavaScript. It exits successfully with no output when there are no errors; otherwise it reports diagnostics. See type-checking setup.

Why is my default import an object? ​

A native ES module receives the CommonJS package's complete module.exports value, which can be an object containing default; see CommonJS imports and export shapes.

Use a documented named export if the package provides one. Otherwise, check the package's documented entry points for an ESM-compatible export. Changing esModuleInterop does not change native ESM imports.

Why does top-level await fail? ​

Top-level await requires ESM execution. Rename the file to .mts to make that file explicitly ESM, and update imports that refer to its old name. If the file must stay CommonJS, put the asynchronous work inside an async function instead. See the runnable top-level-await example.

I found a bug in tsx. What should I do? ​

Create the smallest project that still reproduces the problem. Include:

  • The command you ran, expected behavior, and full error.
  • Your Node.js and tsx versions (node --version and npx tsx --version).
  • Relevant source files, package.json, and tsconfig.json.
  • Your operating system and package manager.

If an equivalent JavaScript example fails under plain node, that comparison can help locate the problem. Include what you observed; you do not need to identify the root cause before reporting a reproducible failure.

File a bug report. For usage questions, use the support options below.

How does tsx compare with ts-node? ​

tsx combines esbuild-based execution, CommonJS/ESM integration, and watch mode in one CLI, without requiring the TypeScript compiler to run code. ts-node integrates with the TypeScript compiler and can type-check during execution.

Use tsx when you want that combined execution workflow and a separate type-checking step; check its compiler limitations if your code requires type-aware transformation.

The TypeScript runtime comparison provides additional comparisons; check the tested versions when interpreting its results.

Can/should tsx be used in production? ​

You can run an application with tsx, or build JavaScript ahead of time and run the output with Node.js. These are different deployment approaches:

  • Run with tsx: deploy the source, required configuration, and tsx as a runtime dependency. If your deployment omits development dependencies, a development-only installation will not be available.
  • Build first: deploy the generated JavaScript and its runtime dependencies. Test the built output, since a build tool can use different resolution or transformation settings.

For either approach, type-check separately and test with the Node.js version, dependencies, and configuration used in deployment. Measure startup and resource use for your workload rather than assuming one approach is faster.

Who uses tsx? ​

See companies and open-source projects using tsx for repository examples.

Ask a question ​

Sponsors can ask usage questions in the support discussions. For sponsorship or consultation inquiries, use the contact page.