Skip to main content
Skip to main content

Install Pricing Module in Medusa

In this document, you'll learn how to install the Pricing module using NPM in the Medusa backend.

Step 1: Install Module

To install the Pricing module, run the following command in the root directory of the Medusa backend:

npm install @medusajs/pricing

Step 2: Add Module to Configurations

In medusa-config.js, add the pricing module to the exported object under the modules property:

medusa-config.js
module.exports = {
// ...
modules: {
// ...
pricingService: {
resolve: "@medusajs/pricing",
},
},
}

Step 3: Run Migrations

Run the following command to reflect schema changes into your database:

npx medusa migrations run

Use the Module

You can now start using the module's PricingModuleService by resolving it through dependency injection.

For example:

import type { 
MedusaRequest,
MedusaResponse
} from "@medusajs/medusa";
import {
PricingModuleService
} from "@medusajs/pricing"

export async function GET(
req: MedusaRequest,
res: MedusaResponse
) {
const pricingModuleService = req.scope.resolve(
"pricingModuleService"
)

return res.json({
pricings: pricingModuleService.list()
})
}
Tip

In the Examples or API Reference guides, you may see an initialization of the pricing module. This is only necessary if you're using the module outside the Medusa backend.


Up Next

Was this section helpful?