medusajs/medusa · warning
File ${entry.name} in policies directory does not export any
Error message
File ${entry.name} in policies directory does not export any policies What it means
The policies loader scans a policies directory, imports each file, and checks whether at least one export is a valid policy (a function or object matching the policy shape). If none qualifies, the file contributes nothing and a console.warn is printed; the rest of policy loading continues.
Source
Thrown at packages/core/utils/src/policies/discover-policies.ts:63
return
}
if (
excludedExtensions.some((ext) => entry.name.endsWith(ext)) ||
excludedFiles.includes(entry.name)
) {
return
}
// Import the file - this will execute definePolicies() calls
const fileExports = await dynamicImport(join(scanDir, entry.name))
// Validate that at least one export is a policy
const values = Object.values(fileExports)
const hasPolicies = values.some((value) => isPolicyExport(value))
if (!hasPolicies) {
console.warn(
`File ${entry.name} in policies directory does not export any policies`
)
}
})
)
})
)
}
View on GitHub (pinned to 5e06e544a2)
Solutions
- Ensure the file exports at least one valid policy (the expected function/object shape per isPolicyExport)
- Move helper/barrel files out of the policies directory, or prefix them so the loader skips them
- Remove dead scaffolding files from the policies folder
Defensive patterns
Strategy: validation
Validate before calling
const exports = await import(filePath)
if (!Object.values(exports).some(isPolicyExport)) {
console.warn(`${filePath} has no policies; move it out of the policies dir`)
} Type guard
const isPolicyFile = (exports: Record<string, unknown>) => Object.values(exports).some((v) => typeof v === "function")
Prevention
- Only put policy modules in the policies directory
- Keep barrels/helpers elsewhere
When it happens
Trigger: A file in the scanned policies directory exporting only helpers, types, or objects that fail isPolicyExport — e.g. exporting a plain config object, an empty object, or non-function constants.
Common situations: Placing shared utils or barrel (index re-export) files inside the policies folder; refactoring a policy into named exports that no longer match the expected policy shape; leftover scaffolding files.
Related errors
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/7837e2b3d44b65f0.
Report an issue: GitHub.