docs/faq.md
We understand that searching for answers about tsx can be challenging due to its name. However, since tsx is essentially an alias for node and adheres to TypeScript behavior, asking how to do something in tsx might not be the best approach.
Instead, consider these questions:
If your question specifically relates to tsx, you can use the search feature in the documentation or ask a question.
When an ES module imports a CommonJS package, Node.js provides the package's complete module.exports value as the default import. This works for conventional CommonJS packages, including packages that export a function directly.
Some legacy packages compile export default to exports.default instead of assigning the value to module.exports. In an ES module, that leaves the callable value at packageDefault.default. The esModuleInterop TypeScript option does not change imports that run as native ES modules.
Prefer a documented named export when the package provides one. Otherwise, report the package's export mismatch to its maintainer. Package authors should publish explicit exports entries for CommonJS and ESM consumers, with matching type declarations.
If you've confirmed that the bug is in tsx, please file an issue in the tsx GitHub repository. Make sure to include a minimal reproduction of the bug.
<a class="button bug-report" href="https://github.com/privatenumber/tsx/issues/new?assignees=&labels=bug%2Cpending+triage&projects=&template=bug-report.yml" target="_blank"> File a bug report ↗ </a>tsx is recognized by both Node.js and TypeScript as a popular tool for running TypeScript code. It is widely adopted, as indicated by its npm download stats: <a href="https://npm.im/tsx"></a>.
To find more examples of where & how tsx is used, search on GitHub.
ts-node?tsx and ts-node are both tools for running TypeScript in Node.js, each offering different approaches to suit user preferences.
Installation
npx tsx ./script.ts) and comes as a single binary with no peer dependencies.Configuration
tsconfig.json file, making it easy for beginners.Defaults
tsconfig.json settings.Module Support
require() for ESM modules.Syntax and Features
tsconfig.json paths.Speed
Watcher
As a DX bonus, tsx also comes with Watch mode to help you iterate faster!
For a detailed technical comparison, refer to this exhaustive comparison between tsx, ts-node, and other runtimes.
Deciding whether to use tsx in production depends on your specific needs and risk tolerance. Here are a few points to consider:
Here are some questions to help guide your decision:
Ultimately, it's a decision you'll need to make based on your specific production requirements and comfort level with potential risks.
tsx offers support via Discussions for sponsors. If you're a sponsor, feel free to ask more questions there!
<style scoped> .bug-report { @apply text-sm text-white hover:text-white bg-blue-500 hover:bg-blue-600 ; } .logos { @apply flex flex-wrap gap-x-4 gap-y-6 justify-around my-4 py-6 px-4 dark:bg-zinc-800; & :deep(img) { @apply h-10; } } </style>