Raw
1 import { Note } from "docs-ui"
2
3 export const metadata = {
4 title: `Prerequisites for New Projects`,
5 }
6
7 # {metadata.title}
8
9 In this guide, learn about the prerequisites for your Medusa application and storefront before deploying it to Cloud in a new project.
10
11 Alternatively, you can create a project from a starter, as explained in the [Create Projects](../page.mdx) guide.
12
13 ## Who is this guide for?
14
15 This guide is intended for developers and teams deploying their local Medusa applications to Cloud.
16
17 You'll learn what setup steps are necessary for:
18
19 1. Deploying a Medusa application (server and admin dashboard) only;
20 2. Or deploying a Medusa application along with a storefront.
21
22 ---
23
24 ## Prerequisites for Medusa Application
25
26 This section covers the prerequisites for deploying your Medusa application (server and admin dashboard) to Cloud.
27
28 If you're also deploying a storefront with your backend, check the [next section](#prerequisites-for-medusa-application-with-storefront) for additional prerequisites.
29
30 ### Supported Node.js Versions
31
32 Medusa supports the Node.js LTS of the following major versions:
33
34 - 20.x (default)
35 - 22.x
36 - 24.x
37 - 25.x
38
39 <Note>
40
41 Starting from [Medusa v2.19.0](https://github.com/medusajs/medusa/releases/tag/v2.19.0), the Medusa application requires Node.js v20.19.0+ or v22.12.0+. So, if you specify a Node.js version as explained next, make sure it satisfies this requirement.
42
43 </Note>
44
45 #### Specifying Node.js Version
46
47 You can override the default Node.js version for your Medusa application by adding an `engines` field in your `package.json` file:
48
49 ```json title="package.json"
50 {
51 "engines": {
52 "node": ">=22.12.0"
53 }
54 }
55 ```
56
57 Medusa will satisfy this version by the following priority:
58
59 ```mermaid
60 flowchart LR
61 A[Start] --> B{"engines field<br/>specified?"}
62 B -- Yes --> C{"Found minimum secure<br/>version matching range?"}
63 C -- Yes --> D["Use minimum secure<br/>version matching the range"]
64 C -- No --> E["Use minimum version<br/>satisfying the range"]
65 B -- No --> F["Use default<br/>Node.js version (20.x)"]
66 ```
67
68 1. Find the minimum secure version that matches the range specified in the `engines` field. For example, if your `package.json` specifies `>=21.0.0`, Medusa will use Node.js v22.x since v21.x is no longer supported.
69 2. If Medusa can't find the minimum secure version that matches the range, it will use the minimum version that satisfies the range, even if it's not an LTS version.
70 3. If no `engines` field is specified, Medusa will use the default Node.js version (20.x).
71
72 ### Configurations Managed in Cloud
73
74 Your existing Medusa application (server and admin dashboard) doesn't need specific configurations to be deployed to Cloud. Medusa automatically:
75
76 - Creates the necessary [server and worker instances](!docs!/learn/production/worker-mode).
77 - Scales your Medusa application's resources based on the traffic it receives.
78 - Sets up and configures production resources and modules for your Medusa application:
79 - [Redis Caching Module Provider](!resources!/infrastructure-modules/caching/providers/redis)
80 - [Redis Event Module](!resources!/infrastructure-modules/event/redis)
81 - [Redis Locking Module Provider](!resources!/infrastructure-modules/locking/redis)
82 - [Redis Workflow Engine Module](!resources!/infrastructure-modules/workflow-engine/redis)
83 - [S3 File Provider Module](!resources!/infrastructure-modules/file/s3)
84
85 Make sure to remove any of these modules from your `medusa-config.ts` file unless you want to use custom options for them. In that case, you must manually set up and manage those resources externally and configure them in your Medusa application.
86
87 <Note>
88
89 The Caching Module was introduced in [Medusa v2.11.0](https://github.com/medusajs/medusa/releases/tag/v2.11.0) to replace the deprecated Cache Module. If you're still using the Cache Module, make sure to remove it from your `medusa-config.ts` file as well.
90
91 </Note>
92
93 <Note type="warning">
94
95 Do not set `projectConfig.databaseUrl`, `projectConfig.databaseDriverOptions`, or `projectConfig.redisUrl` in your `medusa-config.ts` when deploying to Cloud. Cloud automatically manages the database connection, SSL configuration, connection pooling, and Redis provisioning. Setting these options manually may cause deployment or database migration failures.
96
97 </Note>
98
99 ---
100
101 ## Prerequisites for Medusa Application with Storefront
102
103 This section covers the prerequisites for deploying your Medusa application (server and admin dashboard) along with a storefront to Cloud.
104
105 Make sure to follow these steps in addition to the ones mentioned in the [previous section](#prerequisites-for-medusa-application).
106
107 <Note type="soon">
108
109 Storefront deployment is an experimental feature, and our team is actively working on enhancing it. If you run into any issues, contact support for assistance.
110
111 </Note>
112
113 ### Monorepo Setup
114
115 To deploy your Medusa application along with a storefront, both projects must be set up in a monorepo structure. If you've created your Medusa application after v2.14.0, it's already set up in a monorepo structure.
116
117 To create a monorepo for projects prior to v2.14.0, you need:
118
119 1. Package manager: Cloud supports `npm`, `yarn` (v1, v3, and v4), and `pnpm` as package managers.
120 2. Monorepo tool: You can use [turbo](https://turborepo.com/) or [nx](https://nx.dev/) to manage your monorepo.
121
122 <Note type="warning">
123
124 Cloud storefront builds don't support pnpm 12 yet. If you use pnpm, use pnpm 11, such as `11.26.0`. Learn more in the [Troubleshooting](../../deployments/troubleshooting/page.mdx#storefront-opennextjs-cloudflare-not-found-with-pnpm-12) guide.
125
126 </Note>
127
128 You can structure your monorepo as you see fit. You'll be required to specify the paths to your Medusa application and storefront during the project creation process on Cloud.
129
130 ![Diagram showcasing the monorepo structure with Medusa application and storefront as separate packages](https://res.cloudinary.com/dza7lstvk/image/upload/v1766044505/Cloud/storefront-overview_ebmefz.jpg)
131
132 ### Storefront Supported Node.js Versions
133
134 Medusa uses Node.js v24.x (LTS) to build storefronts. You can't override this version.
135
136 So, ensure that your storefront is compatible with Node.js v24.x.
137
138 <Note type="warning">
139
140 If your storefront's `package.json` has an `engines.node` field that restricts the Node.js version to a range that excludes v24.x (for example, `"22.x"`), the build will fail with a version incompatibility error. Update the field to accept v24.x, for example:
141
142 ```json title="apps/storefront/package.json"
143 {
144 "engines": {
145 "node": ">=22.12.0"
146 }
147 }
148 ```
149
150 </Note>
151
152 ### Build Scripts
153
154 In a monorepo, Medusa doesn't run the `build` script of your root `package.json` file. Instead, it builds your Medusa application and your storefront separately, each targeting only its own package.
155
156 So, instead of a root `build` script, you need:
157
158 1. A `build` script in your Medusa application's `package.json` file that runs the `medusa build` command.
159 2. A `build` script in your storefront's `package.json` file that runs the build command, such as `next build`.
160
161 ```json title="apps/backend/package.json"
162 {
163 "scripts": {
164 "build": "medusa build"
165 // other scripts...
166 }
167 }
168 ```
169
170 Medusa only builds the target package and the workspace packages it depends on. The other packages of your monorepo don't enter the build process. Learn more about the build process in the [Deployments](../../deployments/page.mdx#build-process-for-deployments) guide.
171
172 #### Root Files Available During the Build (Turborepo)
173
174 If you're using `turbo`, Medusa prunes your monorepo down to the package it's building before installing dependencies. As a result, the build only has access to the following files from the root of your monorepo:
175
176 - `package.json`
177 - The lockfile
178 - `pnpm-workspace.yaml`
179 - `turbo.json`
180 - `.gitignore`
181 - `.npmrc`
182
183 Medusa doesn't copy any other root file into the build, along with the packages that the target package doesn't depend on. For example, if a workspace package's `tsconfig.json` file extends a shared `tsconfig.base.json` file at the root, the build fails with the following error, even though the build succeeds locally:
184
185 ```bash
186 error TS5083: Cannot read file '/tsconfig.base.json'.
187 ```
188
189 To fix this, move the shared file into a workspace package, then add that package as a dependency of your Medusa application or storefront. Medusa then includes the file in the build, since it builds the target package along with the workspace packages it depends on.
190
191 This also applies to files that your Medusa application needs at runtime, such as JSON files or fonts. Keep them within your Medusa application, then copy them to the `.medusa/server` directory as part of your `build` script. Learn more in the [Built Assets](!docs!/learn/build#built-assets) documentation.
192
193 If you're using `nx` instead of `turbo`, Medusa doesn't prune your monorepo, so all root files are available during the build.
194
195 ### Prerequisites for Yarn Workspaces
196
197 If you're using `yarn` as your package manager, create the `.yarnrc.yml` file in the root of your monorepo with the following content:
198
199 ```yaml title=".yarnrc.yml"
200 nodeLinker: node-modules
201
202 nmHoistingLimits: workspaces
203 ```
204
205 You set the following configurations:
206
207 1. `nodeLinker: node-modules`: Configures Yarn to install dependencies using the traditional `node_modules` structure, which is required for Medusa applications.
208 2. `nmHoistingLimits: workspaces`: Ensures that dependencies are hoisted only to the workspace level, preventing potential conflicts between packages in the monorepo.
209
210 {/* ### Prerequisites for PNPM Workspaces
211
212 If you're using `pnpm` as your package manager, set up the following configurations in your monorepo.
213
214 First, create the `.npmrc` file in the root of your monorepo with the following content:
215
216 ```text title=".npmrc"
217 auto-install-peers=true
218 strict-peer-dependencies=false
219 shared-workspace-lockfile=false
220 ```
221
222 You set the following configurations:
223
224 1. `auto-install-peers=true`: Ensures that peer dependencies are automatically installed when you install packages, preventing potential issues with missing peer dependencies.
225 2. `strict-peer-dependencies=false`: Allows more flexibility when resolving peer dependencies, which can be helpful in a monorepo setup.
226 3. `shared-workspace-lockfile=false`: Ensures that each package in the monorepo can have its own lockfile, which is necessary for Medusa to resolve dependencies correctly.
227
228 Next, create the `pnpm-workspace.yaml` file in the root of your monorepo with the following content:
229
230 ```yaml title="pnpm-workspace.yaml"
231 packages:
232 - "apps/**"
233 - "!apps/backend/.medusa/**"
234 ```
235
236 This configuration specifies the packages that are part of your pnpm workspace. The example above includes all packages under the `apps` directory, except for the `.medusa` directory within the `backend` package.
237
238 Finally, add the `.npmrc` file to your Medusa application's root directory if it doesn't already exist, with the following content:
239
240 ```text title="apps/backend/.npmrc"
241 public-hoist-pattern[]=*@medusajs/*
242 public-hoist-pattern[]=@tanstack/react-query
243 public-hoist-pattern[]=react-i18next
244 public-hoist-pattern[]=react-router-dom
245 ```
246
247 This configuration ensures that specific dependencies are hoisted to the root `node_modules` directory, which is necessary for Medusa to function correctly. */}
248
249 ### Prerequisites for NPM Workspaces
250
251 If you're using `npm` as your package manager with Turbo, you must add the `packageManager` field to your root `package.json`:
252
253 ```json title="package.json"
254 {
255 "packageManager": "npm@10.9.2"
256 }
257 ```
258
259 Replace `10.9.2` with your installed npm version (run `npm --version` to check). Turborepo requires this field when pruning with NPM workspaces. Without it, the build will fail with a `Missing 'packageManager' field` error.
260
261 If you're also using the [Next.js Starter Storefront](!resources!/nextjs-starter) as your storefront, add the following override in the storefront's `package.json`:
262
263 ```json title="apps/storefront/package.json"
264 {
265 "overrides": {
266 // other overrides...
267 "@medusajs/icons": {
268 "react": "19.0.4",
269 "react-dom": "19.0.4"
270 }
271 }
272 }
273 ```
274
275 This ensures the `@medusajs/icons` package uses compatible versions of `react` and `react-dom` with the Next.js Starter Storefront.
276
277 Also, add the following override in your monorepo's root `package.json`:
278
279 ```json title="package.json"
280 {
281 "overrides": {
282 // other overrides...
283 "react": "19.0.4",
284 "react-dom": "19.0.4"
285 }
286 }
287 ```
288
289 This ensures that all packages in your monorepo use compatible versions of `react` and `react-dom`.
290
291 ### Supported Storefront Frameworks
292
293 Cloud currently supports deploying storefronts built with the following frameworks:
294
295 1. [Next.js](https://nextjs.org/) v15. v16 is also supported if you're not using a [proxy](https://nextjs.org/docs/app/getting-started/proxy).
296 2. [SvelteKit](https://kit.svelte.dev/) v2.40.0+
297 3. [Tanstack Start](https://tanstack.com/start) v1.132.0+ (React and Solid)
298
299 If you're using a different framework for your storefront, contact support to request it.
300
301 ---
302
303 ## Additional Storefront Considerations
304
305 When deploying your storefront to Cloud, there are additional considerations to keep in mind related to the build process, environment variables, and custom domains.
306
307 Refer to the [Storefront](../../storefront/page.mdx) guide for more details on these considerations.
308
309 ---
310
311 ## Next Steps
312
313 Now that you know the prerequisites for deploying your Medusa application and storefront to Cloud, you can create your project.
314
315 Refer to the [Project](../page.mdx) guide to learn how to create a new project on Cloud.