Skip to content

Incompatible with Next.js App Router due to jsonpath dependency (ENOENT module.js error) #301

@rubixvi

Description

@rubixvi

The SDK currently breaks in modern Next.js environments (App Router) due to a transitive dependency on jsonpath, which relies on filesystem-based module resolution. This results in runtime errors when the package is bundled.

Error: ENOENT: no such file or directory, open '.../node_modules/jsonpath/include/module.js [middleware] (ecmascript)'

Environment

  • Next.js (App Router)
  • Node.js runtime (non-edge usage)
  • pnpm (strict node_modules structure)
  • Payload CMS
import { Dub } from 'dub'

const client = new Dub({ token: process.env.DUB_API_KEY })

Running this in a Next.js project causes the build/runtime to fail with the ENOENT error above.

Workarounds

// next.config.js
serverExternalPackages: ['dub'],

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions