|
1
|
import ModuleXErrorSection from '../_sections/common-installation-errors/module-x-error.mdx' |
|
2
|
|
|
3
|
export const metadata = { |
|
4
|
title: `General Errors`, |
|
5
|
} |
|
6
|
|
|
7
|
# {metadata.title} |
|
8
|
|
|
9
|
This troubleshooting guide covers general errors you may encounter while installing or developing with Medusa and how to resolve them. |
|
10
|
|
|
11
|
## Resolve "Cannot find module X" Errors |
|
12
|
|
|
13
|
<ModuleXErrorSection /> |
|
14
|
|
|
15
|
--- |
|
16
|
|
|
17
|
## Cannot Find Module `@medusajs/utils` |
|
18
|
|
|
19
|
If you encounter a TypeScript or build error like the following: |
|
20
|
|
|
21
|
```bash |
|
22
|
Cannot find module '@medusajs/utils' or its corresponding type declarations |
|
23
|
``` |
|
24
|
|
|
25
|
The package `@medusajs/utils` does not exist as a public package. Use `@medusajs/framework/utils` instead. |
|
26
|
|
|
27
|
For example, replace: |
|
28
|
|
|
29
|
{/* eslint-disable @medusajs/import-from-framework-not-internal */} |
|
30
|
|
|
31
|
```ts |
|
32
|
import { MedusaService } from "@medusajs/utils" // wrong |
|
33
|
``` |
|
34
|
|
|
35
|
With: |
|
36
|
|
|
37
|
```ts |
|
38
|
import { MedusaService } from "@medusajs/framework/utils" // correct |
|
39
|
``` |
|
40
|
|
|
41
|
Common utilities and classes available from `@medusajs/framework/utils` include `MedusaService`, `MedusaError`, `Modules`, `InjectManager`, `InjectTransactionManager`, and `MedusaContext`. |
|
42
|
|
|
43
|
--- |
|
44
|
|
|
45
|
## TypeError During `medusa build` Config Loading |
|
46
|
|
|
47
|
If you encounter a `TypeError` like the following during `medusa build` or `medusa start`: |
|
48
|
|
|
49
|
```bash |
|
50
|
TypeError: Cannot read properties of null (reading 'admin') |
|
51
|
at ConfigManager.loadConfig |
|
52
|
``` |
|
53
|
|
|
54
|
This error means one of the required top-level properties in your `medusa-config.ts` is `null` or has an incorrect value. The config loader expects an object to be exported, not `null` or `undefined`. |
|
55
|
|
|
56
|
Check your `medusa-config.ts` and make sure: |
|
57
|
|
|
58
|
1. The file exports a valid configuration object using `defineConfig`. |
|
59
|
2. None of the required properties (`projectConfig`, `admin`, `modules`) are explicitly set to `null`. |
|
60
|
|
|
61
|
A minimal valid configuration looks like: |
|
62
|
|
|
63
|
```ts title="medusa-config.ts" |
|
64
|
import { loadEnv, defineConfig } from "@medusajs/framework/utils" |
|
65
|
|
|
66
|
loadEnv(process.env.NODE_ENV || "development", process.cwd()) |
|
67
|
|
|
68
|
module.exports = defineConfig({ |
|
69
|
projectConfig: { |
|
70
|
databaseUrl: process.env.DATABASE_URL, |
|
71
|
http: { |
|
72
|
storeCors: process.env.STORE_CORS!, |
|
73
|
adminCors: process.env.ADMIN_CORS!, |
|
74
|
authCors: process.env.AUTH_CORS!, |
|
75
|
jwtSecret: process.env.JWT_SECRET || "supersecret", |
|
76
|
cookieSecret: |
|
77
|
process.env.COOKIE_SECRET || "supersecret", |
|
78
|
}, |
|
79
|
}, |
|
80
|
}) |
|
81
|
``` |
|
82
|
|
|
83
|
For the full list of available configuration options, refer to [Configure Medusa](!docs!/learn/configurations/medusa-config). |