Problem
@nuxt/test-utils@4.x lists h3-next(h3@2 RC) as a regular dependency. In projects using Bun, this causes Nitro to non-deterministically resolve h3@2 instead of h3@1 during nuxt dev, producing runtime errors like:
invalid url
at server/middleware/api-middleware.ts
The root cause: Nitro scans the package store to build its module map. When it finds both h3@1.x (from Nuxt/Nitro itself) and h3-next (h3@2, from @nuxt/test-utils), it can resolve some code paths to v2. This creates an H3Event structure mismatch — Nitro creates events with h3@2's internal shape while utility functions like getRequestURL expect h3@1's shape.
This affects nuxt dev, not just test runs, because the package is installed as a devDependency and Bun's package scanner sees h3-next in the store regardless of when it is imported.
Environment
@nuxt/test-utils: ^4.0.2
nuxt: ^4.2.1
- Package manager: Bun
Suggested fix
Declare h3-next as an optional peer dependency rather than a regular dependency:
{
"peerDependencies": {
"h3-next": "*"
},
"peerDependenciesMeta": {
"h3-next": { "optional": true }
}
}
This means h3-next is never automatically installed into a consuming project, eliminating the conflict for all Nuxt 4 projects that haven't migrated to h3@2 yet. The longer-term fix is for Nuxt/Nitro to fully migrate to h3@2, at which point h3-next can be dropped entirely.
Problem
@nuxt/test-utils@4.xlistsh3-next(h3@2 RC) as a regular dependency. In projects using Bun, this causes Nitro to non-deterministically resolve h3@2 instead of h3@1 duringnuxt dev, producing runtime errors like:The root cause: Nitro scans the package store to build its module map. When it finds both
h3@1.x(from Nuxt/Nitro itself) andh3-next(h3@2, from@nuxt/test-utils), it can resolve some code paths to v2. This creates an H3Event structure mismatch — Nitro creates events with h3@2's internal shape while utility functions likegetRequestURLexpect h3@1's shape.This affects
nuxt dev, not just test runs, because the package is installed as a devDependency and Bun's package scanner seesh3-nextin the store regardless of when it is imported.Environment
@nuxt/test-utils:^4.0.2nuxt:^4.2.1Suggested fix
Declare
h3-nextas an optional peer dependency rather than a regular dependency:This means
h3-nextis never automatically installed into a consuming project, eliminating the conflict for all Nuxt 4 projects that haven't migrated to h3@2 yet. The longer-term fix is for Nuxt/Nitro to fully migrate to h3@2, at which pointh3-nextcan be dropped entirely.