Skip to main content

Medusa CLI

The Medusa CLI is a command-line tool that provides essential commands for managing your Medusa commerce application. It handles development workflows, database operations, builds, and user management.

Installation

The Medusa CLI is installed as part of the @medusajs/cli package:
npm install @medusajs/cli
Or with Yarn:
yarn add @medusajs/cli
The CLI requires Node.js version 20 or higher.

Usage

Once installed, you can use the medusa command in your terminal:
medusa <command> [options]

Available Commands

The Medusa CLI provides the following commands:

Development & Build

  • medusa develop - Start the development server with file watching
  • medusa start - Start the production server
  • medusa build - Build your Medusa project for production

Database Operations

  • medusa db:setup - Create database, run migrations, and sync links
  • medusa db:create - Create the database
  • medusa db:migrate - Run pending migrations
  • medusa db:migrate:scripts - Run migration scripts
  • medusa db:rollback [modules...] - Rollback migrations for specified modules
  • medusa db:generate [modules...] - Generate migration files for modules
  • medusa db:sync-links - Sync database schema with defined links

Project Setup

  • medusa new [root] [starter] - Create a new Medusa project

User Management

  • medusa user - Create a new user or invitation

Plugin Development

  • medusa plugin:build - Build plugin for publishing
  • medusa plugin:develop - Start plugin development in watch mode
  • medusa plugin:publish - Publish plugin to local registry
  • medusa plugin:add [plugin_names...] - Add plugins from local registry
  • medusa plugin:db:generate - Generate migrations for plugin modules

Utilities

  • medusa exec [file] [args..] - Run a function defined in a file
  • medusa codemod <codemod-name> - Run automated code transformations
  • medusa telemetry - Enable or disable anonymous usage data collection

Global Options

The following options are available for all commands:
  • --verbose - Turn on verbose output
  • --no-color - Turn off colored output
  • --json - Turn on JSON logger format
  • -h, --help - Show help information
  • -v, --version - Show CLI and Medusa version

Version Information

To check the CLI version and Medusa version in your project:
medusa --version
Output:
Medusa CLI version: 2.13.3
Medusa version: 2.13.3
  Note: this is the Medusa version for the site at: /path/to/your/project

Project Detection

Most commands (except medusa new) must be run inside a Medusa project directory. The CLI detects a Medusa project by checking for @medusajs/medusa or @medusajs/cli in your package.json dependencies. If you run a command outside of a Medusa project, you’ll see:
The "<command>" command must be run inside a Medusa project. Make sure you are in the root directory of a Medusa project and try again.

Next Steps

Build docs developers (and LLMs) love