Skip to main content
The run command starts your Native Desktop application in development mode, allowing you to test and develop your application with live updates and debugging capabilities.

Prerequisites

Before running your project, ensure:
  • Your project has been created using native-desktop create
  • All dependencies are installed (npm install)
  • You have a valid native-desktop.config.json5 configuration file

Basic Usage

To run your application in development mode, open the terminal in the root directory of your Native Desktop project and run:
This command will:
  1. Load your project configuration
  2. Compile your TypeScript code
  3. Start the application runtime
  4. Launch your application window

Command Options

[project-config-file] (Optional)

Path to the project configuration file.
  • Type: String (positional argument)
  • Default: native-desktop.config.json5
  • Example: custom-config.json5

Development Features

When running in development mode, you get access to several helpful features:

Hot Reload

Your application automatically reloads when you make changes to your source code, allowing for rapid development and testing.

Debug Console

Access to developer tools and debug console for troubleshooting and inspecting your application’s behavior.

Error Messages

Detailed error messages and stack traces to help identify and fix issues quickly.

Live Testing

Test your application’s functionality in real-time without needing to rebuild after every change.

Complete Examples

Using Default Configuration

Using Custom Configuration

Development Workflow

A typical development workflow looks like this:
  1. Start Development Server
  2. Make Code Changes
    • Edit your source files in the src/ directory
    • Application will automatically reload
  3. Test Features
    • Interact with your application
    • Check console for errors or logs
  4. Iterate and Refine
    • Make additional changes
    • Test again until satisfied
  5. Run Quality Checks

Configuration File

The run command reads settings from your project configuration file. Here’s a basic structure:
Development mode typically enables additional debugging features that are disabled in production builds.

Common Use Cases

Testing New Features

Debugging Issues

UI/UX Development

Integration Testing

Stopping the Application

To stop the running application:
  • Close the application window, or
  • Press Ctrl+C in the terminal where the command is running

Common Issues

Error: Configuration file not found: native-desktop.config.json5Solution: Ensure the configuration file exists in your project root.
Error: Port 3000 is already in useSolution: Stop other applications using the same port or change the port in your configuration.
Error: Cannot find module 'xyz'Solution: Install missing dependencies.
Error: TypeScript compilation failedSolution: Fix TypeScript errors in your code.
Error: Application window doesn’t appearSolution: Check terminal for error messages and verify configuration.

Performance Tips

Clean Cache

Periodically clean build caches if you experience slow startup times or unexpected behavior.

Optimize Dependencies

Remove unused dependencies to improve startup time and reduce application size.

Use TypeScript

TypeScript provides better development experience with type checking and IntelliSense.

Monitor Resources

Keep an eye on CPU and memory usage during development to identify performance issues early.

Development vs Production

Understanding the differences between development and production modes:
Always test your application with native-desktop build before releasing to ensure production behavior matches your expectations.

Keyboard Shortcuts

When running in development mode, you can use keyboard shortcuts (platform-dependent):
  • Reload: Cmd+R (macOS) / Ctrl+R (Windows/Linux)
  • DevTools: Cmd+Option+I (macOS) / Ctrl+Shift+I (Windows/Linux)
  • Quit: Cmd+Q (macOS) / Alt+F4 (Windows/Linux)

Environment Variables

You can use environment variables to customize the development environment:

Multiple Configurations

You can maintain multiple configuration files for different environments:
Then run with the appropriate configuration:

Best Practices

Keep It Running

Keep the development server running while coding to see changes immediately.

Watch for Errors

Monitor the terminal for errors and warnings during development.

Regular Testing

Test frequently during development to catch issues early.

Clean Builds

Occasionally restart the dev server for a fresh start, especially after major changes.

Logs and Debugging

Viewing Logs

Application logs are displayed in the terminal where you ran the command:

Debug Mode

Enable verbose logging for more detailed information:

Integration with Code Editors

The run command works seamlessly with popular code editors:

VS Code

Create a launch configuration:

WebStorm

Create a Node.js run configuration pointing to the Native Desktop CLI.