gh-pages

TypeScript

zx is written in TypeScript and provides the corresponding libdefs out of box. Typings are TS 4+ compatible.

// script.ts
import { $ } from 'zx'

const list = await $`ls -la`

Some runtimes like Bun or Deno have built-in TS support. Node.js requires additional setup. Configure your project according to the ES modules contract:

Using TypeScript compiler is the most straightforward way.

::: code-group

npm install typescript

tsc script.ts

node script.js
npm install ts-node

ts-node script.ts
# or via node loader
node --loader ts-node/esm script.ts
npm install swc-node

swc-node script.ts
npm install tsx

tsx script.ts
bun script.ts
deno run --allow-read --allow-sys --allow-env --allow-run script.ts

:::