close
Documentation content

Quickstart

Install scriptc, compile a TypeScript file, and run the resulting executable.

Prerequisites

  • macOS 15+ on arm64 or x64, Linux on arm64 or x64, or Windows on x64. See Platform Support for target details.
  • Node.js 24 or later and npm for installation. The installed native compiler and its output run without Node.js. Standalone distributions are available from GitHub Releases.
  • A platform linker and SDK for executable builds. On macOS, install the Xcode Command Line Tools. IR, LLVM IR, assembly, and object output use bundled tools and do not require an external linker or SDK.

Install

$ npm install -g scriptc

Keep optional dependencies and installation scripts enabled so npm can install the native command for your platform. For development from a source checkout, see the repository.

Create a program

Create hello.ts:

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

This program reads the first command-line argument, or uses "world" when no argument is provided.

Compile and run

Use scriptc run to compile and execute the program:

$ scriptc run hello.ts
hello, world

To pass arguments, build an executable and invoke it directly:

$ scriptc build hello.ts -o hello >/dev/null
$ ./hello scriptc
hello, scriptc

This program compiles statically, so the executable does not include a JavaScript engine. The shell examples use POSIX syntax; on Windows, build hello.exe and invoke it with .\hello.exe.

Check compilation support

scriptc coverage analyzes a program without creating an executable:

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

$ scriptc coverage hello.ts

  statements analyzed   2
  compile statically    2  (100%)

  fully static — this program has no dynamic remainder.

For programs that need dynamic execution or contain unsupported operations, the report lists the affected sites and diagnostic codes. See Coverage Reports.

Use an npm dependency

Create cli.ts:

cli.ts
import pc from "picocolors";

console.log(pc.green("hello"));

Install the package and enable the embedded engine with --dynamic:

$ npm install picocolors
$ scriptc build cli.ts --dynamic -o demo >/dev/null
$ ./demo
hello

The package's JavaScript is embedded at build time. The executable does not read node_modules at runtime. See npm Dependencies for package resolution, type declarations, and runtime behavior.

Next steps