Zero-config TypeScript toolchain for any environment.
Run, build, scaffold and type-check TypeScript with a single command, or call the same features from your own code through a fully typed API.
Installation · Quick Start · Commands · API · Templates · Structure · Troubleshooting · Windows · FAQ
Setting up TypeScript on a phone usually means writing a tsconfig.json by hand, installing a compiler, and fixing native binaries that do not match the device. SudoType wraps that into one CLI. It uses tsx to run files and esbuild to compile them. esbuild ships native android-arm64 binaries that work in Termux, and tsx runs on top of it.
| Run without a build step Execute .ts files directly, with watch mode. |
Project scaffolding Start from Express, Discord bot, CLI or basic templates. |
| Fast compile Bundle to a single JavaScript file with esbuild. |
Environment checksudotype doctor reports what is missing. |
| Typed programmatic API Import build, init, check and more from TypeScript. |
Works anywhere Termux, Linux, macOS and Windows on Node.js 20.12+. |
- Node.js
20.12or newer (thediscordtemplate usesprocess.loadEnvFile()) - Termux (Android, ARM64), or any Linux / macOS / Windows machine with Node.js
git(optional, used bysudotype init)
SudoType is plain JavaScript on top of esbuild and tsx, so it runs anywhere Node.js 20.12+ and esbuild run.
| Platform | Status |
|---|---|
| Termux (Android, ARM64) | Primary target |
| Linux (x64, ARM64), WSL, Docker, Raspberry Pi, Codespaces | Supported |
| Linux on Android (proot-distro, UserLAnd, Andronix) | Supported |
| macOS (Intel, Apple Silicon) | Supported |
| Windows (x64, ARM64) | Supported (see Windows notes) |
| FreeBSD, OpenBSD, ChromeOS (Crostini) | Should work, not tested |
| iOS (iSH, a-Shell) | Not supported |
CI runs the test suite on Ubuntu, macOS and Windows with Node.js 20, 22 and 24.
Termux (Android)
pkg update && pkg install nodejs git
npm install -g @arraynothere/sudotypeLinux / macOS / Windows
npm install -g @arraynothere/sudotypeThe npm package is @arraynothere/sudotype, and the command it installs is sudotype.
Or run it without installing:
npx @arraynothere/sudotype doctorAs a library (to use the API in your own project)
npm install @arraynothere/sudotypeUpdate or remove it:
npm update -g @arraynothere/sudotype
npm uninstall -g @arraynothere/sudotypeVerify the setup:
sudotype --version
sudotype doctor
You can call tsx and esbuild directly, but you still have to wire up the tsconfig.json, the build flags, the project layout and the environment checks yourself. SudoType puts those behind one command and ships ready-made templates, so a fresh phone goes from zero to a running TypeScript project in a few commands.
1. Run a file
echo 'console.log("Hello from SudoType");' > hello.ts
sudotype run hello.ts2. Create a project
sudotype init my-api --template express --install
cd my-api3. Develop, check and build
sudotype watch src/index.ts # restart on change
sudotype check # type-check
sudotype build src/index.ts # output: dist/index.js| Command | Description |
|---|---|
sudotype run <file.ts> [args] | Run a TypeScript file |
sudotype watch <file.ts> | Run and restart on file changes |
sudotype build [entry] | Bundle to JavaScript with esbuild |
sudotype init [name] | Scaffold a new project |
sudotype check | Type-check with tsc --noEmit |
sudotype tsconfig | Write a ready-to-use tsconfig.json |
sudotype doctor | Diagnose the environment |
Arguments after the file name are passed to your program.
sudotype run src/index.ts --port 8080
sudotype watch src/index.tsThe entry file defaults to src/index.ts. Dependencies stay external unless --bundle-deps is set.
sudotype build # src/index.ts -> dist/index.js
sudotype build src/cli.ts --minify
sudotype build src/index.ts -f cjs -o out/app.cjs --sourcemap
sudotype build src/index.ts --bundle-deps # single self-contained file| Option | Default | Description |
|---|---|---|
-o, --out <file> | dist/<name>.js (.cjs / .mjs when the format differs from "type") | Output file |
-f, --format <esm|cjs> | from package.json "type" | Output module format |
--target <target> | node20 | esbuild target |
--minify | off | Minify the output |
--sourcemap | off | Emit a source map |
--bundle-deps | off | Bundle node_modules into the output |
Run it without arguments for an interactive prompt, or pass everything as flags.
sudotype init # interactive
sudotype init my-bot -t discord --install # flags only
sudotype init my-cli -t cli --no-git| Option | Description |
|---|---|
-t, --template <name> | basic, express, discord or cli |
-i, --install | Run npm install after scaffolding |
--no-git | Skip git init |
sudotype check # requires typescript in the project
sudotype tsconfig # fails if tsconfig.json exists
sudotype tsconfig --force # overwrite
sudotype doctor # exit code 1 if a problem is foundEverything the CLI does is also available as a typed API. The package ships its own type definitions, so no @types/* package is needed for SudoType itself (your project still needs @types/node, which TypeScript projects on Node.js normally have).
npm install @arraynothere/sudotypeimport { build, check, doctor, init, listTemplates, SudoTypeError } from "@arraynothere/sudotype";
// Scaffold a project
const project = await init({ name: "my-api", template: "express", git: false });
console.log(project.directory);
// Bundle a file
const result = await build({ cwd: project.directory, entry: "src/index.ts", minify: true });
console.log(`${result.outfile} (${result.size} bytes in ${result.duration}ms)`);
// Type-check and capture the output
const { success, output } = await check({ cwd: project.directory, silent: true });
if (!success) console.error(output);CommonJS works too:
const { build } = require("@arraynothere/sudotype");Differences from the CLI:
- API functions never call
process.exit()and never print. They return a result or throw aSudoTypeError. - Paths are resolved against the
cwdoption (defaultprocess.cwd()). build()is silent by default. PasslogLevel: "warning"to see esbuild warnings.init()does not prompt. Interactive prompts exist only in the CLI.- Requires Node.js 20.12 or newer, like the CLI.
| Function | Returns | Description |
|---|---|---|
build(options?) | Promise<BuildResult> | Bundle a TypeScript entry file with esbuild |
check(options?) | Promise<CheckResult> | Run tsc --noEmit with the project's TypeScript |
doctor(options?) | Promise<DoctorReport> | Inspect the environment |
init(options) | Promise<InitResult> | Scaffold a project from a template |
listTemplates() | TemplateInfo[] | List the built-in templates |
installDependencies(dir, options?) | Promise<boolean> | Run npm install in a directory |
writeTsconfig(options?) | { path: string } | Write the recommended tsconfig.json |
run(file, args?, options?) | Promise<number> | Run a file with tsx, resolves to the exit code |
watch(file, args?, options?) | Promise<number> | Run a file and restart on changes |
version | string | Installed SudoType version |
SudoTypeError | class | Error type thrown by every function |
| Option | Type | Default | Description |
|---|---|---|---|
entry | string | "src/index.ts" | Entry file |
out | string | dist/<name>.js | Output file |
format | "esm" | "cjs" | from "type" | Module format |
target | string | "node20" | esbuild target |
minify | boolean | false | Minify the output |
sourcemap | boolean | false | Emit a source map |
bundleDeps | boolean | false | Bundle node_modules |
cwd | string | process.cwd() | Working directory |
logLevel | "silent" | "error" | "warning" | "info" | "silent" | esbuild log level |
Result: { entry, outfile, format, size, duration }. entry and outfile are absolute paths, size is in bytes and duration in milliseconds.
| Option | Type | Default | Description |
|---|---|---|---|
cwd |
string |
process.cwd() |
Project directory |
args |
string[] |
[] |
Extra arguments for tsc |
silent |
boolean |
false |
Capture output in result.output instead of printing it |
Result: { success, exitCode, output }. A project with type errors resolves with success: false. It only rejects when TypeScript is missing or cannot start.
const report = await doctor();
// {
// platform: "linux", arch: "x64", termux: false,
// ok: true, problems: 0,
// checks: [{ id: "node", status: "ok", message: "Node.js v22.0.0" }, ...]
// }Each check has an id (node, esbuild, tsx, typescript, git), a status (ok, warn or error), a message and an optional hint. Only error counts as a problem.
| Option | Type | Default | Description |
|---|---|---|---|
name |
string |
required | Project and directory name |
template |
"basic" | "express" | "discord" | "cli" |
"basic" |
Template to use |
cwd |
string |
process.cwd() |
Parent directory |
git |
boolean |
true |
Run git init |
install |
boolean |
false |
Run npm install afterwards |
silent |
boolean |
false |
Hide npm output |
Result: { name, template, directory, installed }.
import { run, watch } from "@arraynothere/sudotype";
const code = await run("src/index.ts", ["--port", "8080"]);
const controller = new AbortController();
const done = watch("src/index.ts", [], { signal: controller.signal });
controller.abort(); // stop watching
await done.catch(() => {}); // an aborted process rejects with code "ABORTED"| Option | Type | Default | Description |
|---|---|---|---|
cwd |
string |
process.cwd() |
Working directory |
env |
NodeJS.ProcessEnv |
process.env |
Environment variables |
stdio |
"inherit" | "pipe" | "ignore" |
"inherit" |
Child stdio |
signal |
AbortSignal |
none | Stops the process when aborted |
onSpawn |
(child: ChildProcess) => void |
none | Called with the child process after it starts |
Every function throws (or rejects with) a SudoTypeError. Branch on error.code, not on the message:
import { build, SudoTypeError } from "@arraynothere/sudotype";
try {
await build({ entry: "src/missing.ts" });
} catch (err) {
if (err instanceof SudoTypeError && err.code === "ENTRY_NOT_FOUND") {
console.error(err.message);
} else {
throw err;
}
}| Code | Thrown by | Meaning |
|---|---|---|
ENTRY_NOT_FOUND | build | The entry file does not exist |
ESBUILD_UNAVAILABLE | build | esbuild failed to load (run doctor) |
INVALID_FORMAT | build | format is not "esm" or "cjs" |
BUILD_FAILED | build | esbuild reported errors (see error.cause) |
TYPESCRIPT_NOT_INSTALLED | check | The project has no typescript package |
INVALID_NAME | init | Missing or invalid project name |
UNKNOWN_TEMPLATE | init | The template does not exist |
DIRECTORY_NOT_EMPTY | init | The target directory already has files |
TEMPLATE_MISSING | init | Template files are missing, reinstall SudoType |
TSCONFIG_EXISTS | writeTsconfig | tsconfig.json exists and force is not set |
FILE_NOT_FOUND | run, watch | The file does not exist |
INVALID_ARGUMENT | run, watch | No file was given |
TSX_NOT_FOUND | run, watch | tsx is missing, reinstall SudoType |
SPAWN_FAILED | check, run, watch | The child process could not start |
ABORTED | run, watch | The signal option aborted the process |
SudoType's types use the exports field, so use a modern module resolution mode:
{
"compilerOptions": {
"module": "Node16",
"moduleResolution": "Node16"
}
}"moduleResolution": "Bundler" works as well. The generated tsconfig.json from sudotype tsconfig already uses a compatible setup. All types (BuildOptions, BuildResult, CheckResult, DoctorReport, InitOptions, RunOptions, TemplateName, ...) are exported:
import type { BuildOptions, DoctorReport } from "@arraynothere/sudotype";| Template | Description | Extra dependencies |
|---|---|---|
basic | Minimal TypeScript project | none |
express | REST API server listening on PORT (default 3000) | express |
discord | Discord bot with a /ping slash command | discord.js v14 |
cli | Command-line app using node:util parseArgs | none |
Every generated project includes these scripts, so the global sudotype command must be installed:
npm start # sudotype run src/index.ts
npm run dev # sudotype watch src/index.ts
npm run build # sudotype build src/index.ts --minify
npm run check # sudotype checkThe Discord template reads DISCORD_TOKEN and CLIENT_ID from .env:
cp .env.example .env # fill in the values
sudotype run src/deploy-commands.ts
sudotype run src/index.tsmy-api/
├── src/
│ └── index.ts
├── .env.example (express, discord)
├── .gitignore
├── package.json
├── README.md
└── tsconfig.json
The discord template also contains src/deploy-commands.ts.
sudotype/
├── bin/
│ └── sudotype.js CLI entry point
├── src/
│ ├── index.js programmatic API entry (package "main")
│ ├── index.d.ts type definitions for the API
│ ├── errors.js SudoTypeError
│ ├── core/ API implementation (no printing, no process.exit)
│ ├── cli.js command dispatcher
│ ├── utils.js shared helpers
│ └── commands/ CLI adapters: run, build, init, check, tsconfig, doctor
├── templates/ basic, express, discord, cli
├── test/
│ ├── smoke.test.js CLI tests
│ ├── api.test.js programmatic API tests
│ └── types/ type-definition tests (tsc)
├── assets/ README badges and graphics
├── CHANGELOG.md
├── CONTRIBUTING.md
├── icon/ project icons
├── tsconfig.base.json
└── package.json
esbuild fails to start
pkg upgrade
npm install -g @arraynothere/sudotype --force
sudotype doctorNode.js version is too old
pkg upgrade nodejs
node --version # must be 20.12 or newersudotype check says TypeScript is not installed
check uses the TypeScript version of the current project:
npm install -D typescript @types/nodeThe Discord template says Missing DISCORD_TOKEN but my .env is filled in
process.loadEnvFile() needs Node.js 20.12 or newer. Check with node --version and upgrade if needed.
command not found: sudotype
npm config get prefix # the bin folder must be in PATH
npm install -g @arraynothere/sudotype- Use PowerShell, Command Prompt or WSL. All commands work the same way.
sudotype init --installrunsnpm.cmdthrough the shell, so Node.js must be on yourPATH.- Press
Ctrl+Cto stoprunandwatch.
Why not Bun?
Bun does not run natively on Termux because it needs glibc. tsx and esbuild work on Android (Bionic) without extra layers.
Does it work outside Termux?
Yes. SudoType runs on any system with Node.js 20.12 or newer, including Linux, macOS and Windows. See Supported platforms.
Can I use SudoType from my own code?
Yes.
npm install @arraynothere/sudotype and import the functions, see the Programmatic API. The CLI is a thin layer on top of the same functions.
Do I need to install tsx or esbuild myself?
No. Both are dependencies of SudoType.
check is the exception: it uses the typescript package of your own project.
git clone https://github.com/arraynothere/sudotype.git
cd sudotype
npm install
npm test # CLI and API tests
npm run test:types # type definitions
node bin/sudotype.js doctorPull requests and issues are welcome at github.com/arraynothere/sudotype. Maintainers: see CONTRIBUTING.md for the release process.
See CHANGELOG.md for release notes.
Released under the MIT License.
Made by Array