Guide · Open source
How to use tsx: run TypeScript in Node.js without compiling
Updated · written with AI from the project's own documentation and checked against our catalogue data
tsx (TypeScript Execute) is a command-line tool that runs TypeScript code in Node.js directly, so you do not have to compile it to JavaScript first. This guide is for developers who already use Node.js, and for learners running TypeScript examples from a terminal. The source README is truncated and mostly covers branding and sponsor links, so this page sticks to what it confirms and points you to the official documentation for details.
Quick start
- 1Confirm Node.js is installed. tsx requires Node.js, so make sure Node.js is available on your machine before you start.
- 2Open the getting started guide. Go to https://tsx.hirok.io/getting-started to find the install command for your setup, since the README excerpt does not include one.
- 3Add tsx with your package manager. Install the tsx package from npm using the method the getting started guide describes.
- 4Run a TypeScript file. Use tsx from the terminal to run a TypeScript file in Node.js, following the usage shown in the official docs.
- 5Test type checking behaviour. Run a file with a deliberate type error to see whether tsx reports it, before relying on it for checks.
What tsx is and who it is for
tsx is described in its README as 'TypeScript Execute' and as the easiest way to run TypeScript in Node.js. Its core idea is that you run a TypeScript file without a separate compile-to-JavaScript step.
It suits developers who want to run TypeScript scripts quickly, people trying out TypeScript code without setting up a build pipeline, and learners running examples from a terminal. It is licensed under MIT and is written in TypeScript.
- Best for: developers already using Node.js who want to run TypeScript scripts quickly
- Best for: trying out TypeScript code without a build pipeline
- Best for: learners running TypeScript examples from a terminal
- Not for: anyone not using Node.js, since the tool runs TypeScript in Node.js
What you need before you start
The only prerequisite listed in the source is Node.js. Install Node.js first, then add tsx to your project through a package manager. The source gives the package name as tsx on npm.
The README excerpt does not include install commands, so check the official getting started page at https://tsx.hirok.io/getting-started for the exact command for your setup.
- Node.js installed on your machine
- A package manager to add the tsx package (the source names npm)
Check whether tsx type-checks your code
The README excerpt does not show whether tsx performs type checking at run time. Because tsx is a runner, do not assume it will catch type errors before your code runs.
If type checking matters for your project, verify this behaviour in the official documentation or with a small test file before you depend on it.
- Test with a file that contains a deliberate type error and see what happens
- Check the documentation at https://tsx.hirok.io before relying on it for checks
Where to find the full documentation
The README links to the project documentation and a getting started guide. The excerpt provided to us does not include usage examples, flags or options, so those details are not covered here.
Use the official docs for commands, configuration and features, since they are the source of truth for the current tool.
- Documentation: https://tsx.hirok.io
- Getting started: https://tsx.hirok.io/getting-started
- Source repository: https://github.com/privatenumber/tsx
What people use it for
- Running a quick TypeScript script in Node.js without a build step
- Trying out TypeScript code examples from a terminal
- Learning TypeScript by running small example files
- Executing TypeScript utility scripts in a Node.js project
Frequently asked questions
What is tsx?
tsx (TypeScript Execute) is a command-line tool that runs TypeScript code in Node.js directly. Its README calls it the easiest way to run TypeScript in Node.js. It removes the need to compile your code to JavaScript first.
Do I need Node.js to use tsx?
Yes. Node.js is the only prerequisite listed in the source, and tsx is described as a way to run TypeScript in Node.js. If you do not use Node.js, this tool is not a fit.
Is tsx free to use?
tsx is released under the MIT licence, according to the project information. The MIT licence allows use under its terms, so check the licence file in the repository for the full text.
Does tsx check types when it runs my code?
The README excerpt does not say whether tsx performs type checking at run time. Test this with a file containing a deliberate type error before relying on it.
How do I install tsx?
The source gives the npm package name as tsx and lists no install commands in the excerpt. Follow the getting started guide at https://tsx.hirok.io/getting-started for the exact steps.
What are the alternatives to tsx?
The project information lists no comparable projects, so this guide cannot compare tsx with others. Check the official documentation and your own testing to decide which tool fits your project.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
tsx suits Node.js developers, learners and anyone who wants to run TypeScript files from a terminal without a build pipeline. Pick something else if you are not using Node.js or need confirmed type checking at run time, since the available source does not show that tsx does it.
Install options & downloads