Medusa Installation

Install Node.js (version 20 or above). Now Ubuntu will install a lower version when trying to install via - "sudo apt install nodejs" so follow the below method. You may install the latest version available by checking the download section of Node.js website.

# installs nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash

# download and install Node.js (you may need to restart the terminal)
nvm install 22

# verifies the right Node.js version is in the environment
node -v # should print `v22.10.0`

# verifies the right npm version is in the environment
npm -v # should print `10.9.0`

Next Install git CLI

sudo apt install git

For latest version you may add below PPA and update git

sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

Finally we will need PostgreSQL for database management - click here for installation instructions

Once PostgreSQL is installed we need to create and new user and assign superuser rights to the user. Then we need to create a new Database and make the new user, the owner of the new Database.

Go to DB console

sudo -u postgres psql

Create new user (password needs single quotes)

CREATE USER medusa WITH ENCRYPTED PASSWORD 'yourpass';

Grant SUPERUSER rights (this is needed, else Medusa installation fails while performing database migration)

ALTER USER medusa WITH SUPERUSER;
ALTER USER medusa WITH CREATEDB;

Create new database

CREATE DATABASE medusadb;
GRANT ALL PRIVILEGES ON DATABASE medusadb TO medusa;

Now we begin Medusa Installation using below command. Note we need to have a database already created in the previous step and have its user name, password and database name

npx create-medusa-app@latest --db-url "postgres://username:password@localhost:5432/database_name"
npx create-medusa-app@latest --db-url "postgres://medusa:password@localhost:5432/medusadb"

Then follow the prompt and enter your project name, whether you want to create store front (Next.js based). After about 5 - 10 minutes your installation will complete and your server will start.

Last updated