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.json5configuration file
Basic Usage
To run your application in development mode, open the terminal in the root directory of your Native Desktop project and run:- Load your project configuration
- Compile your TypeScript code
- Start the application runtime
- 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:-
Start Development Server
-
Make Code Changes
- Edit your source files in the
src/directory - Application will automatically reload
- Edit your source files in the
-
Test Features
- Interact with your application
- Check console for errors or logs
-
Iterate and Refine
- Make additional changes
- Test again until satisfied
-
Run Quality Checks
Configuration File
Therun 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+Cin the terminal where the command is running
Common Issues
Configuration File Not Found
Configuration File Not Found
Error:
Configuration file not found: native-desktop.config.json5Solution: Ensure the configuration file exists in your project root.Port Already in Use
Port Already in Use
Error:
Port 3000 is already in useSolution: Stop other applications using the same port or change the port in your configuration.Module Not Found Error
Module Not Found Error
Error:
Cannot find module 'xyz'Solution: Install missing dependencies.TypeScript Compilation Error
TypeScript Compilation Error
Error:
TypeScript compilation failedSolution: Fix TypeScript errors in your code.Application Won't Start
Application Won't Start
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:| Feature | Development (run) | Production (build) |
|---|---|---|
| Hot Reload | ✅ Enabled | ❌ Disabled |
| DevTools | ✅ Enabled | ❌ Disabled |
| Source Maps | ✅ Enabled | ⚠️ Optional |
| Minification | ❌ Disabled | ✅ Enabled |
| Optimization | ❌ Minimal | ✅ Full |
| Startup Time | ⚠️ Slower | ✅ Faster |
| File Size | ⚠️ Larger | ✅ Smaller |
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: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
Therun command works seamlessly with popular code editors: