Skip to main content

Summary

bun add -d @vitest/coverage-v8 installs the latest version (v4.x) regardless of which vitest version you’re using (v3.x). The mismatch produces a cryptic error: SyntaxError: The requested module 'vitest/node' does not provide an export named 'BaseCoverageProvider'. The fix: always pin the coverage package to match your vitest major version.

The Error

SyntaxError: The requested module 'vitest/node' does not provide an export named 'BaseCoverageProvider'
 ❯ ModuleJob._instantiate node:internal/modules/esm/module_job:213:21
 ❯ loadProvider node_modules/@vitest/coverage-v8/dist/load-provider-CdgAx3rL.js:4:33

The Fix

# Check your vitest version first
bun list vitest
# vitest@3.2.4

# Pin coverage to match
bun add -d @vitest/coverage-v8@^3.2

Why This Happens

Bun (and npm) resolve @vitest/coverage-v8 independently from vitest. Since coverage-v8 v4.x published first, bun add grabs it. The internal API (BaseCoverageProvider) changed between v3 and v4, causing the import failure.

Prevention

In monorepos with multiple packages, script the install:
for pkg in schema fingerprint crdt graph ir n8n-exporter cli doctrines; do
  cd packages/$pkg && bun add -d @vitest/coverage-v8@^3.2 && cd ../..
done