Steps to Reproduce 1. Install Mastra with Zod 3.25.76 2. Run npm run dev (which runs mastra dev) 3. Server crashes during initialization
Error
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './v4' is not defined by "exports" in mastra-app/node_modules/zod/package.json imported from mastra-app/.mastra/output/index.mjs at exportsNotFound (node:internal/modules/esm/resolve:314:10) at packageExportsResolve (node:internal/modules/esm/resolve:662:9)
Root Cause
Mastra is attempting to import zod/v4 subpath, which only exists in Zod 4.x: • Zod 4.1.x: Exports zod/v4 subpath • Zod 3.x: Does not export zod/v4 subpath
Expected Behavior
Mastra should: 1. Option A: Auto-detect Zod version and use correct imports (zod for v3, zod/v4 for v4) 2. Option B: Explicitly require Zod 4.x in peer dependencies if v4-specific features are needed 3. Option C: Avoid importing zod/v4 and use standard zod import that works with both versions
Context
According to the Mastra changelog (2025-09-08), Zod v4 support was added while maintaining full v3 compatibility. However, the import path zod/v4 breaks that compatibility.
Workaround Attempted • Tried upgrading to Zod 4.1.13, but this breaks AI SDK compatibility:
AI_APICallError: tools.0.custom.input_schema.type: Field required
AI_APICallError: tools.0.custom.input_schema.type: Field required
(See issue #7234 for context on Zod 4 schema conversion issues)