Skip to main content
The pnpm dev command starts a development server with Hot Module Replacement (HMR) support. When you modify code, changes are instantly reflected without restarting the server.

Basic Usage

Once the development server starts, you can use the following features:
  • Auto-restart: Automatic server restart on code changes
  • TypeScript support: Run .ts files directly
  • Source map support: Accurate line numbers on errors
  • Keyboard shortcuts: Shortcuts for quick actions

Subcommands

You can run API and Web separately. Running API and Web in separate terminals:
pnpm dev web passes arguments after -- directly to Vite. For example, to change the port: bash pnpm dev web -- --port 5174

How It Works

pnpm dev internally uses the following tools: Important: These packages are automatically provided by Sonamu, so no separate installation is needed.

Execution Process

  1. Execute src/index.ts as entry point
  2. Transform and execute TypeScript files immediately
  3. Detect file changes
  4. Replace only changed modules (HMR)
  5. Full restart only when necessary

Keyboard Shortcuts

You can use the following shortcuts while the development server is running:

Shortcut Usage Examples

Server restart:
Force restart (cache reset):

Environment Variables

The development server automatically sets the following environment variables: You can check environment variables in code:

How HMR Works

Cases That Auto-restart

The server automatically restarts when modifying these files:
  • Entity files (*.entity.ts)
  • Model files (*.model.ts)
  • Config files (sonamu.config.ts)
  • Migration files

Cases Reflected Instantly (HMR)

Changes to these files are reflected instantly without server restart:
  • General business logic
  • Utility functions
  • Service layer

Troubleshooting

Server Won’t Start

Problem: Port already in use
Solution:

HMR Not Working

Problem: Code changes not reflected Solution:

TypeScript Errors

Problem: Server won’t start due to type errors Solution:

Practical Tips

1. Fast Development Cycle

Modify code and test immediately:

2. Check Logs

Development server outputs all logs to console:

3. Debugging

Source maps are enabled for accurate line numbers:

Differences from Production

Don’t use development server in production!
  • Slow performance
  • High memory usage
  • Security vulnerabilities
Use pnpm build then pnpm start for production.

Next Steps

build

Build for production

HMR

Learn more about HMR system