Quickstart
In this guide you install scriptc, compile a small TypeScript program into an executable, check what compiles, and add an npm dependency.
Prerequisites
- A supported computer: macOS 15 or later (arm64 or x64), Linux (arm64 or x64), or Windows (x64). See Platform Support for details.
- Node.js 24 or later and npm, to install scriptc. The compiler itself and the executables it builds run without Node.js. Standalone compiler archives are also available from GitHub Releases.
- A linker, to build executables. On macOS, install the Xcode Command Line Tools with
xcode-select --install. On glibc-based Linux, install clang. On Windows and musl-based Linux, install zig.
Install
Install the CLI globally with npm:
npm installs the native compiler for your platform as an optional dependency, so keep optional dependencies and install scripts enabled. Check that it works:
Create a program
Create hello.ts. It greets the name passed on the command line, or world when there is none:
Compile and run
scriptc run compiles the program and runs it immediately:
scriptc build writes an executable instead. It prints the path of the file it writes; the examples in these docs discard that line with >/dev/null:
The executable runs on its own, without Node.js or scriptc installed. scriptc run does not pass extra arguments to the program, so build an executable when you need them.
On Windows, build hello.exe and run it with .\hello.exe.
Check compilation support
Before building a larger program, run scriptc coverage. It analyzes the program without building it and reports how much compiles:
When a program uses an unsupported operation, the report lists each site with a diagnostic code and a hint. See Coverage Reports.
Use an npm dependency
Create cli.ts:
Install the package, then build as usual:
The package compiles into the executable at build time, so the executable doesn't need node_modules when it runs. See npm Dependencies for which packages compile and how to check them.
Next steps
- Coverage Reports: find out whether an existing program compiles.
- Platform Support: cross-compile for Linux, Windows, and WebAssembly.
- CLI Reference: output formats, optimization levels, and other options.
- Limitations: restrictions and differences from Node.js.