medusajs/medusa · critical · Error

Unable to resolve plugin "${pluginPath}". Make sure the plug

Error message

Unable to resolve plugin "${pluginPath}". Make sure the plugin directory has a package.json file

What it means

While collecting Medusa plugins, the loader reads `<pluginPath>/package.json`. If reading fails with MODULE_NOT_FOUND or ENOENT, the path does not point to a resolvable package directory and startup aborts.

Source

Thrown at packages/core/utils/src/common/get-resolved-plugins.ts:39

/**
 * Returns the absolute path to the package.json file for a
 * given plugin identifier.
 */
async function resolvePluginPkgFile(
  rootDirectory: string,
  pluginPath: string
): Promise<{ path: string; contents: any }> {
  try {
    const pkgJSONPath = require.resolve(path.join(pluginPath, "package.json"), {
      paths: [rootDirectory],
    })
    const packageJSONContents = JSON.parse(
      await fs.readFile(pkgJSONPath, "utf-8")
    )
    return { path: pkgJSONPath, contents: packageJSONContents }
  } catch (error) {
    if (error.code === "MODULE_NOT_FOUND" || error.code === "ENOENT") {
      throw new Error(
        `Unable to resolve plugin "${pluginPath}". Make sure the plugin directory has a package.json file`
      )
    }
    throw error
  }
}

/**
 * Reads the "medusa-plugin-options.json" file from the plugin root
 * directory and returns its contents as an object.
 */
async function resolvePluginOptions(
  pluginRootDir: string
): Promise<Record<string, any>> {
  try {
    const contents = await fs.readFile(
      path.join(pluginRootDir, MEDUSA_PLUGIN_OPTIONS_FILE_PATH),
      "utf-8"

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Install the plugin package (yarn add medusa-plugin-foo)
  2. Fix the resolve path to the plugin package root that contains package.json
  3. For local plugins, point at the directory containing package.json (or src per plugin layout)

Example fix

// before
plugins: [{ resolve: "medusa-plugin-myshop" }]
// after (after running: yarn add medusa-plugin-myshop)
plugins: [{ resolve: "medusa-plugin-myshop" }]
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs')
for (const p of config.plugins ?? []) {
  const pkg = require.resolve(`${p.resolve}/package.json`)
  if (!fs.existsSync(pkg)) throw new Error(`plugin ${p.resolve} not installed`)
}

Try / catch

try { defineConfig(config) } catch (e) { if (/Unable to resolve plugin/.test(e.message)) check installs/paths; else throw e }

Prevention

When it happens

Trigger: Listing a plugin in medusa-config `plugins: [{ resolve: "medusa-plugin-foo" }]` where the package isn't installed, is misspelled, or the path lacks a package.json (e.g. pointing at a file or a dist folder only).

Common situations: Forgot to npm/yarn install the plugin, typo in plugin name, pointing resolve at a subfolder like ./plugins/foo/src, or a plugin whose publish config omits files.

Related errors


AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27). Data as JSON: /api/errors/b717eac18361e9a4. Report an issue: GitHub.