|
1
|
export const metadata = { |
|
2
|
title: `Error: make sure your module has a default export of a service.`, |
|
3
|
} |
|
4
|
|
|
5
|
# {metadata.title} |
|
6
|
|
|
7
|
If you get the following error while building your Medusa application: |
|
8
|
|
|
9
|
```bash |
|
10
|
...doesn't seem to have a main service exported -- make sure your module has a default export of a service |
|
11
|
``` |
|
12
|
|
|
13
|
## Why this Error Occurred |
|
14
|
|
|
15
|
This error occurs when you set the `resolve` path of a module provider to point directly to a service file instead of the module directory. |
|
16
|
|
|
17
|
For example, if you set the `resolve` path to `./src/modules/slack/service`: |
|
18
|
|
|
19
|
```ts title="medusa-config.ts" highlights={[["9"]]} |
|
20
|
module.exports = defineConfig({ |
|
21
|
// ... |
|
22
|
modules: [ |
|
23
|
{ |
|
24
|
resolve: "@medusajs/medusa/notification", |
|
25
|
options: { |
|
26
|
providers: [ |
|
27
|
{ |
|
28
|
resolve: "./src/modules/slack/service", |
|
29
|
id: "slack", |
|
30
|
options: { |
|
31
|
channels: ["slack"], |
|
32
|
webhook_url: process.env.SLACK_WEBHOOK_URL, |
|
33
|
admin_url: process.env.SLACK_ADMIN_URL, |
|
34
|
}, |
|
35
|
}, |
|
36
|
], |
|
37
|
}, |
|
38
|
}, |
|
39
|
], |
|
40
|
}) |
|
41
|
``` |
|
42
|
|
|
43
|
You'll get the error because the `resolve` path is pointing to the service file of the module provider, while it should point to the module directory. |
|
44
|
|
|
45
|
--- |
|
46
|
|
|
47
|
## How to Fix it |
|
48
|
|
|
49
|
To fix the error, set the `resolve` path to point to the module directory instead of the service file. For example: |
|
50
|
|
|
51
|
```ts title="medusa-config.ts" highlights={[["9"]]} |
|
52
|
module.exports = defineConfig({ |
|
53
|
// ... |
|
54
|
modules: [ |
|
55
|
{ |
|
56
|
resolve: "@medusajs/medusa/notification", |
|
57
|
options: { |
|
58
|
providers: [ |
|
59
|
{ |
|
60
|
resolve: "./src/modules/slack", |
|
61
|
id: "slack", |
|
62
|
options: { |
|
63
|
channels: ["slack"], |
|
64
|
webhook_url: process.env.SLACK_WEBHOOK_URL, |
|
65
|
admin_url: process.env.SLACK_ADMIN_URL, |
|
66
|
}, |
|
67
|
}, |
|
68
|
], |
|
69
|
}, |
|
70
|
}, |
|
71
|
], |
|
72
|
}) |
|
73
|
``` |