vitest-dev/vitest · error · Error
Benchmark provider loaded from "${provider}" did not have a
Error message
Benchmark provider loaded from "${provider}" did not have a default export. What it means
Thrown by `loadProviderModule` (benchmark.ts:114) when the custom benchmark provider module imports successfully but has no `default` export (`mod.default == null`). Vitest expects the provider object (implementing `BenchmarkProvider.run`) to be the default export; a named-only export or a side-effect module is rejected.
Source
Thrown at packages/vitest/src/runtime/benchmark.ts:114
let cachedProvider: Promise<BenchmarkProvider> | undefined
async function loadProviderModule(
provider: string,
moduleRunner: TestModuleRunner,
): Promise<BenchmarkProvider> {
let mod: Record<string, any>
try {
mod = await moduleRunner.import(provider)
}
catch (error) {
throw new Error(
`Failed to load benchmark provider from "${provider}".`,
{ cause: error },
)
}
if (mod.default == null) {
throw new Error(
`Benchmark provider loaded from "${provider}" did not have a default export.`,
)
}
return mod.default
}
/**
* Resolves the benchmark provider for the current worker, importing a custom
* provider module on first use. The result is cached for the lifetime of the
* worker so a custom provider is imported at most once.
*/
export function resolveBenchmarkProvider(
config: SerializedConfig,
moduleRunner: TestModuleRunner,
): Promise<BenchmarkProvider> {
if (!cachedProvider) {
const provider = config.benchmark.provider
cachedProvider = !providerView on GitHub (pinned to d568f8ce37)
Solutions
- Add `export default { async run(group) { /* return BenchResult[] */ } }` to the provider module.
- Confirm the configured path points to the file with the default export.
- Ensure the default export implements `BenchmarkProvider` (`run(group): Promise<BenchResult[]>`).
Example fix
// before
export const myProvider = { async run(group) { /* ... */ } }
// after
export default { async run(group) { /* return BenchResult[] */ } } Defensive patterns
Strategy: validation
Validate before calling
const mod = await import(providerPath)
if (mod.default == null) throw new Error(`${providerPath} must have a default export`) Type guard
const hasDefaultProvider = (m: Record<string, unknown>): m is { default: { run(g: any): Promise<any[]> } } =>
typeof m.default === 'object' && typeof (m.default as any)?.run === 'function' Prevention
- Always `export default` the provider object.
- Validate that the default export has a `run` function.
- Keep provider authoring consistent with the `BenchmarkProvider` interface.
When it happens
Trigger: Authoring a benchmark provider with `export const provider = { run(...) {} }` and no default export; a provider whose default export is conditionally undefined; pointing at a file that isn't the provider entry.
Common situations: Forgetting `export default` when writing a provider; refactoring that moved the implementation to a named export; loading the wrong module.
Related errors
- The vcsProvider module '${vcsProvider}' doesn't have a defau
- Failed to load benchmark provider from "${provider}".
- Custom CoverageProviderModule loaded from ${options.customPr
- Custom reporter loaded from ${path} was not the default expo
- benchmark provider did not return a result for "${name}"
AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03).
Data as JSON: /data/errors/199f83fe6a4695ab.json.
Report an issue: GitHub.