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'],
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
Running this in a Next.js project causes the build/runtime to fail with the ENOENT error above.
Workarounds