CLI Usage
The ExisJS CLI (exisjs or exis) can be executed through global package managers, on-demand runner utilities like npx, or locally defined package.json scripts.
Execution Methods
1. On-Demand Execution (npx)
When initializing a new application or running ad-hoc commands without a global install:
# Initialize a project in the current working directorynpx exisjs init
# Check environment diagnosticsnpx exisjs doctor
# Print the application routing tablenpx exisjs routes2. Global Installation
For system-wide command availability:
# Install globallynpm install -g exisjs
# Run directlyexisjs devexis routes3. Project-Local Scripts (Recommended)
When working inside an established project, invoking the CLI via npm run ensures consistent execution pinned to the local exisjs dependency in node_modules.
Default Package Scripts
Applications initialized with npx exisjs init include standard npm lifecycle scripts in package.json:
{ "name": "my-exis-app", "version": "1.0.0", "scripts": { "dev": "exisjs dev", "build": "exisjs build", "clean": "exisjs clean", "start": "exisjs start", "test": "exisjs test", "routes": "exisjs routes", "doctor": "exisjs doctor" }, "dependencies": { "exisjs": "^1.0.0" }, "devDependencies": { "@exisjs/cli": "^0.10.0", "typescript": "^5.0.0" }}Run these scripts using your preferred package manager:
# Start development servernpm run dev
# Compile TypeScript and build route manifestsnpm run build
# Start the production server (one process, no CLI needed)npm run start
# Run native test runnernpm test
# Print routing tablenpm run routesPassing Arguments to Scripts
When invoking CLI commands through npm run, use the double-dash delimiter (--) to forward flags and positional arguments to exisjs:
# Run dev server on a custom portnpm run dev -- -p 4000
# Run a specific test filenpm test -- tests/users.test.ts
# Filter routes table by method and pathnpm run routes -- -m POST -f /api/v1With pnpm or yarn:
# pnpm forwards arguments directlypnpm dev -p 4000
# yarn forwards arguments directlyyarn dev -p 4000Environment Configuration
The CLI automatically loads environment variables according to the current execution mode:
| File | Loaded In | Priority |
|---|---|---|
.env.local | All modes (except test) | High |
.env.<mode> | Matching mode (e.g. .env.production) | Medium |
.env | All modes | Default |
Overriding the Environment Mode
Use the -m, --mode <mode> flag or set NODE_ENV:
# Build with staging environment variablesnpx exisjs build --mode staging
# Execute a script under staging configurationnpx exisjs run scripts/seed.ts --mode stagingNext Steps
- Explore the complete command catalog in the CLI Command Reference.
- Review global server configurations in the Configuration Guide.