dev command starts your Loopar application in development mode with hot module replacement (HMR) enabled, making it ideal for local development.
Usage
The dev command does not accept a site name parameter - it always starts the core development site.
What It Does
When you runloopar dev, the following sequence occurs:
- Ensures Dev Site Exists - Runs
ensure-site.jsto create the dev site if it doesn’t exist - Starts PM2 Process - Launches the application using PM2 with the ecosystem configuration
- Displays Status - Shows the status table with site information
Source Code
Here’s how the dev command is implemented:bin/loopar-cli.js
Automatic Site Creation
If thesites/dev directory doesn’t exist, it will be automatically created with the following structure:
Default Configuration
The auto-created.env file contains:
sites/dev/.env
The port where the development server will run
The site name identifier
The tenant identifier for multi-tenancy support
The Node.js environment mode
PM2 Configuration
The dev command uses the ecosystem configuration frombin/loopar.ecosystem.config.mjs:
bin/loopar.ecosystem.config.mjs
Development Features
Hot Module Replacement (HMR)
The dev server includes HMR capabilities, allowing you to see changes in real-time without full page reloads:- Automatic Reloading - Changes to your code are reflected immediately
- State Preservation - Component state is maintained during updates when possible
- Fast Feedback - See your changes in seconds
Process Monitoring
After starting, you’ll see a status table showing:- ID - PM2 process ID
- PID - System process ID
- Namespace - Project namespace
- Site - Site name (dev)
- Port - HTTP port (default 3000)
- HMR - Hot module replacement port
- Link - Direct link to the application
- Status - Current process status
- CPU - CPU usage percentage
- Memory - Memory consumption
- Uptime - Time since the process started
Accessing Your Application
Once started, your development server is accessible at:PORT environment variable in sites/dev/.env.
Troubleshooting
Port Already in Use
If port 3000 is already in use, you can change it:- Edit
sites/dev/.env - Change
PORT=3000to a different port - Restart with
loopar restart dev
Site Not Starting
Check the logs for error messages:PM2 Connection Issues
If PM2 fails to connect, try:Next Steps
View Logs
Monitor your development server logs in real-time
Check Status
View detailed status information about your running processes
Production Deployment
Learn how to start your application in production mode
Process Control
Restart your development server after configuration changes