Skip to main content

medusa develop

Start the Medusa development server with automatic file watching and hot reloading.

Usage

Alias:

Description

The medusa 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

  1. Initializes the Medusa container and loads your configuration
  2. Forks a child process running medusa start
  3. Watches your project files for changes
  4. 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/
When a file is created, modified, or removed, the development server automatically reloads.

Hot Module Replacement (HMR)

By default, the development server uses a standard restart approach. If the backend-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:
Without HMR:

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 HOST environment variable, if set

-p, --port

Set the port for the development server.
  • Type: string
  • Default: Value of PORT environment variable, or 9000

Examples

Basic Usage

Start the development server on the default port:
Output:

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 mode
  • MEDUSA_HMR_ENABLED=true - Set when HMR is enabled

Stopping the Server

To stop the development server, press Ctrl+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 port 9000 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