Quickstart

Install the CLI from npm and compile your first binary in a couple of minutes.

Prerequisites

  • macOS arm64 is the primary platform (Linux and Windows are cross-compilation targets).
  • clang — preinstalled with the Xcode Command Line Tools.
  • Node ≥ 20 — to run the compiler. The binaries it produces need no Node at all.

Install

$ npm install -g scriptc

To work from a clone instead (pnpm install && pnpm build in the repo, then pnpm scriptc from the repo directory), see the repository.

Your first binary

Write ordinary TypeScript:

hello.ts
const who: string = process.argv.length > 2 ? process.argv[2] : "world";
console.log(`hello, ${who}`);

Compile and run in one step:

$ scriptc run hello.ts
hello, world

Or produce the executable:

$ scriptc build hello.ts -o hello
$ ./hello scriptc
hello, scriptc
$ ls -la hello
-rwxr-xr-x  1 you  staff  329752  hello

That is a self-contained native binary — no Node, no node_modules, no JavaScript engine. It starts in about 4ms where Node takes ~35ms to print the same line.

Note the process.argv.length guard in hello.ts: scriptc arrays are dense, so an out-of-bounds read like process.argv[2] with no third argument is a runtime trap, not undefined. This is one of the documented divergences; the compiler and runtime tell you rather than silently differing.

See what compiles

Ask the compiler how static your program is — and what, precisely, isn't:

$ scriptc coverage hello.ts

  statements analyzed   2
  compile statically    2  (100%)

  fully static — this program has no dynamic remainder.

For programs that import npm packages or use any, the report names each dynamic site and each blocker with an error code. See Coverage Reports.

Use an npm dependency

npm packages run in an embedded JavaScript engine, opted in with --dynamic:

cli.ts
import pc from "picocolors";

function banner(text: string): string {
  return pc.bold(pc.green(text));
}

const args = process.argv.slice(2);
console.log(banner("scriptc demo"));
console.log(`args: ${args.length}`);
$ npm install picocolors
$ scriptc build cli.ts --dynamic -o demo
$ ./demo one two
scriptc demo
args: 2

The package's JS is embedded into the binary at build time — the executable never reads node_modules and runs from anywhere. See npm Dependencies for how the boundary works.

Next steps

  • CLI Reference — every command and flag, including --emit-ir, --backend llvm, and --sanitize.
  • Platform Support — cross-compiling to Linux and Windows with zig.
  • Limitations — what doesn't compile yet.