[GH-ISSUE #6759] vitest peerDependency incompatible with Cloudflare vitest pool workers #10616

Closed
opened 2026-04-13 06:51:30 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @awwong1 on GitHub (Dec 14, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6759

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Cloudflare's Vitest Pool Workers has a hard dependency on Vitest 2.0.x to 3.2.x.
https://developers.cloudflare.com/workers/testing/vitest-integration/write-your-first-test/

npm init
npm i -D vitest@~3.2.0 @cloudflare/vitest-pool-workers
npm i better-auth

Current vs. Expected behavior

Observed peer dependency resolution failure.

npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: better-auth@1.4.7
npm error Found: vitest@3.2.4
npm error node_modules/vitest
npm error   peer vitest@"2.0.x - 3.2.x" from @cloudflare/vitest-pool-workers@0.10.15
npm error   node_modules/@cloudflare/vitest-pool-workers
npm error     dev @cloudflare/vitest-pool-workers@"^0.10.15" from the root project
npm error   dev vitest@"~3.2.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peerOptional vitest@"^4.0.15" from better-auth@1.4.7
npm error node_modules/better-auth
npm error   better-auth@"*" from the root project
npm error
npm error Conflicting peer dependency: vitest@4.0.15
npm error node_modules/vitest
npm error   peerOptional vitest@"^4.0.15" from better-auth@1.4.7
npm error   node_modules/better-auth
npm error     better-auth@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error ~/.npm/_logs/2025-12-14T20_00_12_638Z-eresolve-report.txt
npm error A complete log of this run can be found in: ~/.npm/_logs/2025-12-14T20_00_12_638Z-debug-0.log

Expected: better-auth should not impose a vitest peer dependency, vitest is unrelated to production use.

What version of Better Auth are you using?

1.4.7

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T8132",
    "release": "24.6.0",
    "cpuCount": 10,
    "cpuModel": "Apple M4",
    "totalMemory": "32.00 GB",
    "freeMemory": "0.37 GB"
  },
  "node": {
    "version": "v22.18.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.6.1"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {
    "version": "Unknown",
    "config": null
  }
}

Which area(s) are affected? (Select all that apply)

Package

Auth config (if applicable)


Additional context

I tested my reproduction against the latest release.
A workaround exists currently by specifying a package.json override.

{
  ...
  "overrides": {
    "better-auth": {
      "vitest": "~3.2.0"
    }
  }
}
Originally created by @awwong1 on GitHub (Dec 14, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6759 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Cloudflare's Vitest Pool Workers has a hard dependency on Vitest 2.0.x to 3.2.x. https://developers.cloudflare.com/workers/testing/vitest-integration/write-your-first-test/ ```bash npm init npm i -D vitest@~3.2.0 @cloudflare/vitest-pool-workers npm i better-auth ``` ### Current vs. Expected behavior Observed peer dependency resolution failure. ``` npm error code ERESOLVE npm error ERESOLVE could not resolve npm error npm error While resolving: better-auth@1.4.7 npm error Found: vitest@3.2.4 npm error node_modules/vitest npm error peer vitest@"2.0.x - 3.2.x" from @cloudflare/vitest-pool-workers@0.10.15 npm error node_modules/@cloudflare/vitest-pool-workers npm error dev @cloudflare/vitest-pool-workers@"^0.10.15" from the root project npm error dev vitest@"~3.2.0" from the root project npm error npm error Could not resolve dependency: npm error peerOptional vitest@"^4.0.15" from better-auth@1.4.7 npm error node_modules/better-auth npm error better-auth@"*" from the root project npm error npm error Conflicting peer dependency: vitest@4.0.15 npm error node_modules/vitest npm error peerOptional vitest@"^4.0.15" from better-auth@1.4.7 npm error node_modules/better-auth npm error better-auth@"*" from the root project npm error npm error Fix the upstream dependency conflict, or retry npm error this command with --force or --legacy-peer-deps npm error to accept an incorrect (and potentially broken) dependency resolution. npm error npm error npm error For a full report see: npm error ~/.npm/_logs/2025-12-14T20_00_12_638Z-eresolve-report.txt npm error A complete log of this run can be found in: ~/.npm/_logs/2025-12-14T20_00_12_638Z-debug-0.log ``` Expected: `better-auth` should not impose a vitest peer dependency, vitest is unrelated to production use. ### What version of Better Auth are you using? 1.4.7 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T8132", "release": "24.6.0", "cpuCount": 10, "cpuModel": "Apple M4", "totalMemory": "32.00 GB", "freeMemory": "0.37 GB" }, "node": { "version": "v22.18.0", "env": "development" }, "packageManager": { "name": "npm", "version": "11.6.1" }, "frameworks": null, "databases": null, "betterAuth": { "version": "Unknown", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript ``` ### Additional context I tested my reproduction against the latest release. A workaround exists currently by specifying a `package.json` override. ```json { ... "overrides": { "better-auth": { "vitest": "~3.2.0" } } } ```
GiteaMirror added the locked label 2026-04-13 06:51:30 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 14, 2025):

Hi @awwong1! I'm Dosu and I’m helping the better-auth team.

The dependency conflict happens because better-auth@1.4.7 declares Vitest ^4.0.15 as an optional peer dependency, while @cloudflare/vitest-pool-workers requires Vitest 2.x–3.2.x. npm tries to resolve both, but the version ranges are incompatible, resulting in an ERESOLVE error. Vitest is only used for testing in better-auth and is not required for production or runtime use—you can safely omit it if you’re not running the library’s tests yourself. The optional peer dependency was added to expose the version constraint for contributors or consumers who want to run tests, not because it’s needed in production code (source, source).

To work around this, you can use npm’s --legacy-peer-deps or --force flags to bypass the peer dependency check, though this isn’t ideal for long-term setups and may lead to broken or unsupported dependency trees. There’s no official fix or removal of the Vitest peer dependency for this scenario as of the latest release. This pattern of peer dependency conflicts has also affected other packages (like Next.js and Prisma), and maintainers are aware and have released beta versions to address some compatibility issues (example, example).

If you’re only using better-auth in production or outside of its test suite, you can ignore the Vitest peer dependency and safely bypass the error. If you need strict dependency resolution, consider using an alternative package manager like pnpm or yarn, which may be more lenient in some cases. Keep an eye on future releases for a more robust solution.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3651979377 --> @dosubot[bot] commented on GitHub (Dec 14, 2025): <!-- Greeting --> Hi @awwong1! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> The dependency conflict happens because better-auth@1.4.7 declares Vitest ^4.0.15 as an optional peer dependency, while @cloudflare/vitest-pool-workers requires Vitest 2.x–3.2.x. npm tries to resolve both, but the version ranges are incompatible, resulting in an ERESOLVE error. Vitest is only used for testing in better-auth and is not required for production or runtime use—you can safely omit it if you’re not running the library’s tests yourself. The optional peer dependency was added to expose the version constraint for contributors or consumers who want to run tests, not because it’s needed in production code ([source](https://github.com/better-auth/better-auth/pull/6654), [source](https://github.com/better-auth/better-auth/blob/f59fe3a19974805357d3f6dd54731247c0be3f3c/packages/better-auth/package.json#L28-L567)). To work around this, you can use npm’s --legacy-peer-deps or --force flags to bypass the peer dependency check, though this isn’t ideal for long-term setups and may lead to broken or unsupported dependency trees. There’s no official fix or removal of the Vitest peer dependency for this scenario as of the latest release. This pattern of peer dependency conflicts has also affected other packages (like Next.js and Prisma), and maintainers are aware and have released beta versions to address some compatibility issues ([example](https://github.com/better-auth/better-auth/issues/6439), [example](https://github.com/better-auth/better-auth/issues/6746)). If you’re only using better-auth in production or outside of its test suite, you can ignore the Vitest peer dependency and safely bypass the error. If you need strict dependency resolution, consider using an alternative package manager like pnpm or yarn, which may be more lenient in some cases. Keep an eye on future releases for a more robust solution. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/2f513b9a-56c8-47a6-abc2-0660dee2aed0?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/2f513b9a-56c8-47a6-abc2-0660dee2aed0?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/2f513b9a-56c8-47a6-abc2-0660dee2aed0?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/2f513b9a-56c8-47a6-abc2-0660dee2aed0?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/2f513b9a-56c8-47a6-abc2-0660dee2aed0?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/2f513b9a-56c8-47a6-abc2-0660dee2aed0?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/2f513b9a-56c8-47a6-abc2-0660dee2aed0?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20dependency%20conflict%20happens%20because%20better-auth%401.4.7%20declares%20Vitest%20%5E4.0.15%20as%20an%20optional%20peer%20dependency%2C%20while%20%40cloudflare/vitest-pool-workers%20requires%20Vitest%202.x%E2%80%933.2.x.%20npm%20tries%20to%20resolve%20both%2C%20but%20the%20version%20ranges%20are%20incompatible%2C%20resulting%20in%20an%20ERESOLVE%20error.%20Vitest%20is%20only%20used%20for%20testing%20in%20better-auth%20and%20is%20not%20required%20for%20production%20or%20runtime%20use%E2%80%94you%20can%20safely%20omit%20it%20if%20you%E2%80%99re%20not%20running%20the%20library%E2%80%99s%20tests%20yourself.%20The%20optional%20peer%20dependency%20was%20added%20to%20expose%20the%20version%20constraint%20for%20contributors%20or%20consumers%20who%20want%20to%20run%20tests%2C%20not%20because%20it%E2%80%99s%20needed%20in%20production%20code%C2%A0%28%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/pull/6654%29%2C%20%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/blob/f59fe3a19974805357d3f6dd54731247c0be3f3c/packages/better-auth/package.json%23L28-L567%29%29.%0A%0ATo%20work%20around%20this%2C%20you%20can%20use%20npm%E2%80%99s%20--legacy-peer-deps%20or%20--force%20flags%20to%20bypass%20the%20peer%20dependency%20check%2C%20though%20this%20isn%E2%80%99t%20ideal%20for%20long-term%20setups%20and%20may%20lead%20to%20broken%20or%20unsupported%20dependency%20trees.%20There%E2%80%99s%20no%20official%20fix%20or%20removal%20of%20the%20Vitest%20peer%20dependency%20for%20this%20scenario%20as%20of%20the%20latest%20release.%20This%20pattern%20of%20peer%20dependency%20conflicts%20has%20also%20affected%20other%20packages%20%28like%20Next.js%20and%20Prisma%29%2C%20and%20maintainers%20are%20aware%20and%20have%20released%20beta%20versions%20to%20address%20some%20compatibility%20issues%C2%A0%28%5Bexample%5D%28https%3A//github.com/better-auth/better-auth/issues/6439%29%2C%20%5Bexample%5D%28https%3A//github.com/better-auth/better-auth/issues/6746%29%29.%0A%0AIf%20you%E2%80%99re%20only%20using%20better-auth%20in%20production%20or%20outside%20of%20its%20test%20suite%2C%20you%20can%20ignore%20the%20Vitest%20peer%20dependency%20and%20safely%20bypass%20the%20error.%20If%20you%20need%20strict%20dependency%20resolution%2C%20consider%20using%20an%20alternative%20package%20manager%20like%20pnpm%20or%20yarn%2C%20which%20may%20be%20more%20lenient%20in%20some%20cases.%20Keep%20an%20eye%20on%20future%20releases%20for%20a%20more%20robust%20solution.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/6759)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10616