技术事实和测量说明以英文为准,以避免不同翻译之间出现偏差。

Get Started with Perry

From zero to a running native executable in three steps. Native output does not need Node.js or an external JavaScript engine on the target machine; Perry's runtime and GC are linked into it.

开始使用

安装 Perry,开始将 TypeScript 编译为原生可执行文件

1安装

terminal
$ npm install -g @perryts/perry

Recommended cross-platform install. Native targets still require the relevant platform SDK and linker; run perry doctor after installation.

2使用

Verify the toolchain
perry doctor

Checks the compiler, linker, SDK, and target setup

编译文件
perry compile main.ts

将 main.ts 编译为原生可执行文件

自定义输出
perry compile main.ts -o myapp

指定输出可执行文件名称

附带 V8 运行时
perry compile main.ts --enable-js-runtime

启用 V8 以兼容 JavaScript npm 包

检查兼容性
perry check ./src

验证 TypeScript 代码是否可进行原生编译

Your first binary, step by step

Once Perry is installed, compiling TypeScript to a native executable is a single command. Write a file:

hello.ts
const name = process.argv[2] ?? "World";
console.log(`Hello, ${name}!`);

Compile it and run the result — the output is a self-contained machine-code binary, not a bundled script:

terminal

$ perry compile hello.ts

✓ Compiled executable: hello

$ ./hello Perry

Hello, Perry!

The published runtime-only hello-world measurement is about 3.2 ms on the documented Apple M-series test host. Real startup depends on the target, linked features, I/O, and hardware. Read more about how Perry compiles TypeScript to a binary or what happens inside the TypeScript native compiler.

Where to go next