Error: make sure your module has a default export of a service.
If you get the following error while building your Medusa application:
Why this Error Occurred#
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.
For example, if you set the resolve path to ./src/modules/slack/service:
1module.exports = defineConfig({2 // ...3 modules: [4 {5 resolve: "@medusajs/medusa/notification",6 options: {7 providers: [8 {9 resolve: "./src/modules/slack/service",10 id: "slack",11 options: {12 channels: ["slack"],13 webhook_url: process.env.SLACK_WEBHOOK_URL,14 admin_url: process.env.SLACK_ADMIN_URL,15 },16 },17 ],18 },19 },20 ],21})
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.
How to Fix it#
To fix the error, set the resolve path to point to the module directory instead of the service file. For example:
medusa-config.ts1module.exports = defineConfig({2 // ...3 modules: [4 {5 resolve: "@medusajs/medusa/notification",6 options: {7 providers: [8 {9 resolve: "./src/modules/slack",10 id: "slack",11 options: {12 channels: ["slack"],13 webhook_url: process.env.SLACK_WEBHOOK_URL,14 admin_url: process.env.SLACK_ADMIN_URL,15 },16 },17 ],18 },19 },20 ],21})
Was this page helpful?