Skip to content

h3-next dependency causes Nitro to resolve h3@2 over h3@1 in Nuxt 4 projects #1711

@alexiaallanic-arch

Description

@alexiaallanic-arch

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions