medusa develop
Start the Medusa development server with automatic file watching and hot reloading.Usage
Description
Themedusa develop command starts a development server that watches your file system and automatically restarts or reloads when files change. This is the primary command you’ll use during development.
How It Works
- Initializes the Medusa container and loads your configuration
- Forks a child process running
medusa start - Watches your project files for changes
- Automatically reloads or restarts the server when files change
File Watching
The development server watches all files in your project except:- Dot files (files starting with
.) node_modules/dist/static/private/src/admin/.medusa/
Hot Module Replacement (HMR)
By default, the development server uses a standard restart approach. If thebackend-hmr feature flag is enabled, the server will use Hot Module Replacement for faster reloads without a full restart.
With HMR enabled, you’ll see:
Options
--types
Generate automated types for modules inside the .medusa directory.
- Type:
boolean - Default:
true
-H, --host
Set the host for the development server.
- Type:
string - Default: Value of
HOSTenvironment variable, if set
-p, --port
Set the port for the development server.
- Type:
string - Default: Value of
PORTenvironment variable, or9000
Examples
Basic Usage
Start the development server on the default port:Custom Port and Host
Start the development server on a custom port and host:Disable Type Generation
Start the development server without generating types:File Change Example
When you modify a file, you’ll see output like:Environment Variables
The development server sets the following environment variables:NODE_ENV=development- Automatically set to development modeMEDUSA_HMR_ENABLED=true- Set when HMR is enabled
Stopping the Server
To stop the development server, pressCtrl+C in your terminal. The first time you stop the server, you’ll see a message about starring Medusa on GitHub:
Troubleshooting
Port Already in Use
If the default port9000 is already in use, specify a different port:
Server Keeps Restarting
If the server keeps restarting due to programming errors, the development server will continue watching files and allow you to fix the errors without having to re-run the command.See Also
- medusa start - Start production server
- medusa build - Build for production