CLI Reference
Complete reference for tsgonest build and dev commands, flags, and exit codes.
tsgonest provides several subcommands: build for production compilation, check for fast type checking without emit, dev for watch-mode development, and openapi for standalone OpenAPI spec generation. If no subcommand is given, build is assumed.
tsgonest build
Compiles TypeScript via tsgo, generates companion files, and produces the OpenAPI document.
tsgonest build [flags]Flags
| Flag | Alias | Description | Default |
|---|---|---|---|
--project <path> | -p | Path to tsconfig.json | tsconfig.json |
--config <path> | Path to tsgonest.config.json | auto-detect ./tsgonest.config.json | |
--clean | Delete the output directory before building | false | |
--assets | Copy non-TypeScript assets to the output directory | false | |
--no-check | Skip type checking (emit only) | false | |
--dump-metadata | Dump type metadata JSON to stdout and exit | false | |
--version | Print version and exit | ||
--help | Print usage and exit |
Examples
# Default build (uses tsconfig.json + auto-detected config)
tsgonest build
# Custom tsconfig
tsgonest build --project tsconfig.build.json
# Clean build
tsgonest build --clean
# Skip type checking for faster builds
tsgonest build --no-check
# Explicit config path
tsgonest build --config configs/tsgonest.config.json -p tsconfig.build.json
# Dump type metadata for debugging
tsgonest build --dump-metadataExit codes
| Code | Meaning |
|---|---|
0 | Success — no errors |
1 | TypeScript errors found, but JS was still emitted |
2 | Fatal error — JS was not emitted |
tsgonest check
Type check your project and run tsgonest-specific analysis without emitting any files. Catches both TypeScript errors and tsgonest-specific warnings (invalid parameter types, unsupported decorator patterns, anonymous generic arguments, etc.).
tsgonest check [flags]Flags
| Flag | Alias | Description | Default |
|---|---|---|---|
--project <path> | -p | Path to tsconfig.json | tsconfig.json |
--config <path> | Path to tsgonest.config.ts or .json | auto-detect | |
--watch | Re-check on file changes | false | |
--no-check | Skip semantic type checking (syntax errors still reported) | false |
What it checks
- TypeScript diagnostics — syntax and semantic errors (same as
tsc --noEmit) - Controller analysis — validates NestJS decorators, parameter types, and route definitions (14 warning kinds including
param-non-scalar,query-complex-type,unsupported-dynamic-route-path, etc.) - Type walker — detects anonymous generic type arguments that can't be named in OpenAPI
Watch mode
Use --watch for continuous checking during development:
tsgonest check --watchOn each file save the full check pipeline re-runs. Since check skips emit, this is fast enough for interactive use.
Examples
# One-shot check
tsgonest check
# Continuous watch
tsgonest check --watch
# Custom tsconfig
tsgonest check --project tsconfig.build.json
# Skip type checking for tsgonest-only analysis
tsgonest check --no-checkExit codes
| Code | Meaning |
|---|---|
0 | No errors (warnings may be present) |
1 | TypeScript errors found |
tsgonest dev
Watch-mode development server. Watches source files, rebuilds on changes, and restarts your Node.js process.
tsgonest dev [flags] [-- node-args...]Flags
| Flag | Description | Default |
|---|---|---|
--project <path> | Path to tsconfig.json | tsconfig.json |
--config <path> | Path to tsgonest.config.json | auto-detect |
--entry <file> | Entry point TypeScript file | auto-detect from config or src/main.ts |
--exec <command> | Custom command to run instead of node | node |
--env-file <path> | Load environment variables from file (repeatable) | |
--debug | Enable Node.js inspector (--inspect) | false |
--preserveWatchOutput | Don't clear the terminal on rebuild | false |
--no-source-maps | Disable source map generation | false |
Behavior
- Initial build — Runs a full
tsgonest buildon startup. - Start process — Launches
node dist/<entry>.js(or the custom--execcommand). - Watch — Monitors
src/(orsourceRootfrom config) for file changes. - Rebuild — On file change, clears the terminal, runs an incremental build, and restarts the process.
- Manual restart — Type
rs+ Enter to trigger a manual rebuild and restart (whenmanualRestartis enabled in config).
Passthrough arguments
Arguments after -- are passed directly to the Node.js process:
# Pass --inspect-brk to Node.js
tsgonest dev -- --inspect-brk
# Pass environment variables
tsgonest dev -- --max-old-space-size=4096Examples
# Basic watch mode
tsgonest dev
# With custom entry point
tsgonest dev --entry src/main.ts
# With environment file
tsgonest dev --env-file .env --env-file .env.local
# With Node.js debugger
tsgonest dev --debug
# With custom build config
tsgonest dev --project tsconfig.build.json --config tsgonest.config.json
# Don't clear terminal on rebuild
tsgonest dev --preserveWatchOutputtsgonest openapi
Generate OpenAPI documents without running a full build. Skips TypeScript emit, companion file generation, SDK generation, and asset copying. Useful for CI/CD pipelines, documentation publishing, and API diff checks.
tsgonest openapi [flags]Flags
| Flag | Alias | Description | Default |
|---|---|---|---|
--config <path> | Path to tsgonest.config.ts or .json | auto-detect | |
--project <path> | -p | Path to tsconfig.json | tsconfig.json |
--output <path> | Override the output path (single-output mode only) | from config | |
--name <name> | Generate only the named output (multi-output mode) | all outputs | |
--no-check | Skip type checking (syntax errors still reported) | false |
Examples
# Generate from default config
tsgonest openapi
# Generate only the "public" output from a multi-output config
tsgonest openapi --name public
# Override output path
tsgonest openapi --output dist/api-spec.json
# Skip type checking for faster generation
tsgonest openapi --no-check
# Use a specific config
tsgonest openapi --config tsgonest.public.config.tsPath Alias Resolution
tsgonest automatically resolves TypeScript path aliases (paths in tsconfig.json) in the compiled output. Import statements like @app/users/user.dto are rewritten to relative paths in the emitted JavaScript — no additional tooling (like tsconfig-paths or tsc-alias) required.
{
"compilerOptions": {
"paths": {
"@app/*": ["src/*"],
"@shared/*": ["src/shared/*"]
}
}
}// Source
import { UserDto } from '@app/users/user.dto';
// Compiled output — path alias resolved automatically
import { UserDto } from './users/user.dto.js';Implicit build
If you run tsgonest without a subcommand but with flags that start with -, it is treated as tsgonest build:
# These are equivalent:
tsgonest build --project tsconfig.build.json
tsgonest --project tsconfig.build.jsonVersion
tsgonest --version
# tsgonest v0.3.0