Install Medusa with create-medusa-app
In this document, you’ll learn how to use create-medusa-app to set up a Medusa backend and an admin dashboard.
Overview
Medusa is a toolkit for developers to create digital commerce applications. In its simplest form, Medusa is a Node.js backend with the core API, plugins, and modules installed through npm.
create-medusa-app
is a command that facilitates creating a Medusa ecosystem. It installs the Medusa backend and admin dashboard, along with the necessary configurations to run the backend.
create-medusa-app
uses a beta version of the admin dashboard. If you want to use a stable Medusa setup, you can install the stable backend and the admin using the following guides:
Prerequisites
Before you can install and use Medusa, you need the following tools installed on your machine:
How to Create a Medusa Project
Make sure your PostgreSQL server is running before you run the command.
In your terminal, run the following command:
Available Options
--repo-url <url>
: The repository URL to create the project from. By default it will behttps://github.com/medusajs/medusa-starter-default
.--seed
: A flag indicating whether the database should be seeded with demo data. By default, seeding is disabled.--no-boilerplate
: A flag that removes all files added for an enhanced onboarding experience (files undersrc/admin
,src/api
, etc...). This is helpful if you want to create a clean project, and is only recommended if you're familiar with Medusa.
Step 1: Specify Project Name
You’ll first be asked to enter the name of your project, which is used to create the directory holding your Medusa backend. You can use the default my-medusa-store
or enter another project name.
(Optional) Step 2: Specify PostgreSQL credentials
By default, this command will try to use the default PostgreSQL credentials to connect to your PostgreSQL server. If they don't work, you'll be prompted to enter your PostgreSQL database and passowrd. If they work, you can move ahead to the next step.
These credentials will be used to create a database during this setup and configure your Medusa backend to connect to that database.
Step 3: Enter an admin email
You'll then be prompted to enter an admin email for your admin user. You'll be using this admin email later to login to your admin dashboard. You can use the default admin@medusa-test.com
or enter any other email.
Step 4: Wait for Project Setup
After the above steps, the project setup will start which includes:
- Creating the project directory. The directory name will be the project name you entered in step 1.
- Creating the project database.
- Installing dependencies in your project directory.
- Building project and running migrations to migrate the Medusa schema into your project database.
- Create the admin user.
- Seeding the database with demo data.
Step 5: Log into admin dashboard
Once the project is prepared, the Medusa backend will start and the admin dashboard will be opened in your default browser. You'll then be asked to enter a password for the admin email you entered earlier, as well as other account information.
Once you're logged in, you can start using Medusa! Try following the setup guide to create your first product and order.
Next Steps: Start your Development
Based on what you're building, you can find a development path for you in the Recipes page.
Find learning paths based on what you're building
Troubleshooting
EAGAIN error
When using the create-medusa-app
npx command, you might run into an NPM EAGAIN
error. This error can randomly occur due to conflicting processes.
The easiest solution is to start the command over. Alternatively, if your setup crossed the "create database" point, you can manually perform the following steps in the directory of your created project. You can skip any steps that you're sure have been performed by create-medusa-app
:
1. Install dependencies:
2. Build project:
3. Run migrations:
4. Create an admin user:
5. Optionally seed the database:
6. Start project:
TypeError: cmd is not a function
This error typically occurs when you set up a Medusa project with create-medusa-app
and try to run the Medusa backend.
To resolve this issue, make sure you change into the backend
directory of the Medusa project you created before trying to start the Medusa backend:
Error: connect ECONNREFUSED ::1:5432
When you start your Medusa backend you may run into the following error:
This error occurs because the backend couldn't connect to the PostgreSQL database. The issue could be one of the following:
- PostgreSQL server isn't running. Make sure it's always running while the Medusa backend is running.
- The connection URL to your PostgreSQL database is incorrect. This could be because of incorrect credentials, port number, or connection URL format. The format should be
postgres://[user][:password]@[host][:port]/[dbname]
. Make sure that the connection URL format is correct, and the credentials passed in the URL are correct. You can learn more about formatting the connection URL here
AwilixResolutionError: Could Not Resolve X
If you get the error on a fresh installation of the Medusa backend, or you haven't made any customizations that would cause this error, try to remove the node_modules
directory, then run the following command in the root directory of the Medusa backend to re-install the dependencies:
Other Errors
If you ran into another error, please try to search through our GitHub issues to see if there's a solution for your issue. If not, please create an issue on GitHub and our team will help you resolve it soon.