M
Mastra•4w ago
kareulo

Mastra won't build due to "ZodOptional" is not exported by ".mastra/.build/zod.mjs"

Hey guys, is there a way to get around this error?
Ī» bun run build
$ mastra build
INFO [2025-11-19 22:44:14.986 +0800] (Mastra CLI): Analyzing dependencies...
INFO [2025-11-19 22:44:17.741 +0800] (Mastra CLI): Optimizing dependencies...
INFO [2025-11-19 22:44:43.171 +0800] (Mastra CLI): Bundling Mastra application
ERROR [2025-11-19 22:44:47.216 +0800] (Mastra CLI): Failed during bundler bundle stage: node_modules/@mastra/schema-compat/dist/index.js (2:12): "ZodOptional" is not exported by ".mastra/.build/zod.mjs", imported by "node_modules/@mastra/schema-compat/dist/index.js".
domain: "DEPLOYER"
category: "SYSTEM"
details: {}
error: script "build" exited with code 1
Ī» bun run build
$ mastra build
INFO [2025-11-19 22:44:14.986 +0800] (Mastra CLI): Analyzing dependencies...
INFO [2025-11-19 22:44:17.741 +0800] (Mastra CLI): Optimizing dependencies...
INFO [2025-11-19 22:44:43.171 +0800] (Mastra CLI): Bundling Mastra application
ERROR [2025-11-19 22:44:47.216 +0800] (Mastra CLI): Failed during bundler bundle stage: node_modules/@mastra/schema-compat/dist/index.js (2:12): "ZodOptional" is not exported by ".mastra/.build/zod.mjs", imported by "node_modules/@mastra/schema-compat/dist/index.js".
domain: "DEPLOYER"
category: "SYSTEM"
details: {}
error: script "build" exited with code 1
Here's my package.json
{
"name": "redacted",
"private": true,
"type": "module",
"scripts": {
"build": "mastra build",
"check": "biome check",
"dev": "mastra dev",
"start": "mastra start"
},
"dependencies": {
"@ai-sdk/openai": "^2.0.68",
"@aws-sdk/client-s3": "^3.934.0",
"@aws-sdk/s3-request-presigner": "^3.934.0",
"@mastra/ai-sdk": "^0.2.7",
"@mastra/core": "^0.24.1",
"@mastra/libsql": "^0.16.2",
"@mastra/loggers": "^0.10.19",
"@mastra/memory": "^0.15.11",
"@mastra/pg": "^0.17.8",
"@mastra/pinecone": "^0.11.16",
"@mastra/rag": "^1.3.4",
"@t3-oss/env-core": "^0.13.8",
"dedent": "^1.7.0",
"docx": "^9.5.1",
"exceljs": "^4.4.0",
"pdf-lib": "^1.17.1",
"pptxgenjs": "^4.0.1",
"zod": "^4.1.12"
},
"devDependencies": {
"@biomejs/biome": "^2.3.6",
"@types/bun": "^1.3.2",
"mastra": "^0.18.1",
"typescript": "^5.9.3"
},
"packageManager": "bun@1.3.2"
}
{
"name": "redacted",
"private": true,
"type": "module",
"scripts": {
"build": "mastra build",
"check": "biome check",
"dev": "mastra dev",
"start": "mastra start"
},
"dependencies": {
"@ai-sdk/openai": "^2.0.68",
"@aws-sdk/client-s3": "^3.934.0",
"@aws-sdk/s3-request-presigner": "^3.934.0",
"@mastra/ai-sdk": "^0.2.7",
"@mastra/core": "^0.24.1",
"@mastra/libsql": "^0.16.2",
"@mastra/loggers": "^0.10.19",
"@mastra/memory": "^0.15.11",
"@mastra/pg": "^0.17.8",
"@mastra/pinecone": "^0.11.16",
"@mastra/rag": "^1.3.4",
"@t3-oss/env-core": "^0.13.8",
"dedent": "^1.7.0",
"docx": "^9.5.1",
"exceljs": "^4.4.0",
"pdf-lib": "^1.17.1",
"pptxgenjs": "^4.0.1",
"zod": "^4.1.12"
},
"devDependencies": {
"@biomejs/biome": "^2.3.6",
"@types/bun": "^1.3.2",
"mastra": "^0.18.1",
"typescript": "^5.9.3"
},
"packageManager": "bun@1.3.2"
}
4 Replies
Mastra Triager
Mastra Triager•3w ago
šŸ“ Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10272 šŸ” If you're experiencing an error, please provide a minimal reproducible example to help us resolve it quickly. šŸ™ Thank you @kareulo for helping us improve Mastra!
Ward
Ward•3w ago
https://github.com/mastra-ai/mastra/pull/10470 should fix this, it should go out later today or you can try the beta
GitHub
fix(deployer): Disable treeshake in analyzeEntry by LekoArts Ā· Pul...
Description Fix bundling failure when imports are declared but never used Problem Users encountered build errors when importing multiple exports from a package but only using some of them: import {...
Ward
Ward•2w ago
Seems similar to https://github.com/mastra-ai/mastra/issues/5149 so i'm pretty sure it got fixed
GitHub
[BUG] Bundling Error: createQueryVectorTool fails the build if not ...
Describe the Bug When you have a tool in the tools directory that uses createQueryVectorTool, but that tool isn't used by an agent you get the following error: error: { "binding": &qu...
LekoArts
LekoArts•2w ago
A new 0.x version is out with a fix, please update your mastra versions to the latest version šŸ‘

Did you find this page helpful?