Describe the Bug
Description
@mastra/core uses npm aliases in its dependencies (e.g., "@ai-sdk/provider-utils-v5": "npm:@ai-sdk/provider-utils@3.0.20"). These synthetic package names don't exist on npm — they only resolve if the package manager installs them into a flat node_modules. With pnpm's default strict symlink structure, they aren't available at runtime in Vercel's serverless environment.
Every server route crashes with:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@ai-sdk/provider-utils-v5'
The app works perfectly locally. This only manifests in the Vercel serverless runtime.
This appears to be the same root cause as #8775 (closed Oct 2025 against @mastra/core@0.20.2), but the problem persists in @mastra/core@1.24.0.
Stack
- Framework: Nuxt 4 (Nitro serverless)
- Package manager: pnpm 10
- Deployment: Vercel (serverless functions)
- Mastra packages:
@mastra/core@^1.24.0, @mastra/memory@^1.15.0, @mastra/pg@^1.9.0, @mastra/ai-sdk@^1.3.3
What we tried (in order)
1. public-hoist-pattern in .npmrc — already in place, did not fix
public-hoist-pattern[]=@ai-sdk/*
public-hoist-pattern[]=@mastra/*
Hoisting patterns alone don't resolve npm aliases — pnpm still creates symlinks that Vercel's file tracer doesn't follow.
2. Adding aliased deps explicitly to package.json — did not fix
Added the aliased packages directly:
"@ai-sdk/provider-utils-v5": "npm:@ai-sdk/provider-utils@3.0.20"
Deployed, same error.
3. nitro.externals.inline for @mastra/* — partially worked
Inlined @mastra/* packages so the bundler resolves aliases at build time. The error shifted from referencing chunk-SE7ST47S.js to index.mjs — inlining partially worked but something still referenced the aliased package name at runtime.
Also tried installing the aliased AI SDK deps + inlining them together — still failed.
4. nitro.noExternals: true — broke the build
Switched to bundling everything. This broke because resend optionally imports @react-email/render which isn't installed. Worked around that with rollupConfig.external but the alias issue still wasn't fully resolved.
5. Also added @mastra/schema-compat aliased deps — still not enough
Discovered @mastra/schema-compat also uses npm aliases (zod-v3, zod-from-json-schema-v3). Added those too. Still failed — the alias whack-a-mole kept finding new unresolved packages.
6. Switching from pnpm to npm — aliases resolved but bundle too large
Removed pnpm entirely and switched to npm. npm's flat node_modules resolved all aliases natively, but the resulting Vercel serverless function exceeded the 250MB size limit, so this wasn't viable.
7. shamefully-hoist=true — did not fix
Reverted to pnpm with shamefully-hoist=true. Still uses symlinks under the hood, which Vercel's file tracer doesn't follow for aliased packages.
8. node-linker=hoisted — current workaround ✅
# .npmrc
node-linker=hoisted
This tells pnpm to create a flat, non-symlinked node_modules layout (like npm) while still benefiting from pnpm's deduplication, keeping the bundle under Vercel's 250MB limit.
Suggestion
The root cause is @mastra/core depending on npm aliases for AI SDK packages. This is fragile because:
- pnpm (default mode) and Yarn PnP don't guarantee flat resolution of aliases
- Serverless bundlers/tracers (Vercel, Netlify) may not follow symlinks
- It requires users to configure their package manager to work around Mastra's internal dependency strategy
Ideally, @mastra/core would avoid npm aliases in its published package.json, or the Nuxt integration guide and deployment docs would document this requirement. (Note: the web framework deployment page currently covers Next.js and Astro but not Nuxt.)
Steps To Reproduce
- Create a Nuxt 4 app with
@mastra/core@^1.24.0
- Use pnpm with default settings (no
node-linker=hoisted)
- Deploy to Vercel
- Any server route that imports from
@mastra/core will crash with ERR_MODULE_NOT_FOUND
Link to Minimal Reproducible Example
Workaround in place.
Expected Behavior
Server routes importing @mastra/core should work on Vercel with pnpm's default settings without requiring node-linker=hoisted.
Environment Information
Binaries:
Node: 22.20.0
npm: 10.9.3
pnpm: 10.32.1
Verification
Describe the Bug
Description
@mastra/coreuses npm aliases in its dependencies (e.g.,"@ai-sdk/provider-utils-v5": "npm:@ai-sdk/provider-utils@3.0.20"). These synthetic package names don't exist on npm — they only resolve if the package manager installs them into a flatnode_modules. With pnpm's default strict symlink structure, they aren't available at runtime in Vercel's serverless environment.Every server route crashes with:
The app works perfectly locally. This only manifests in the Vercel serverless runtime.
This appears to be the same root cause as #8775 (closed Oct 2025 against
@mastra/core@0.20.2), but the problem persists in@mastra/core@1.24.0.Stack
@mastra/core@^1.24.0,@mastra/memory@^1.15.0,@mastra/pg@^1.9.0,@mastra/ai-sdk@^1.3.3What we tried (in order)
1.
public-hoist-patternin.npmrc— already in place, did not fixHoisting patterns alone don't resolve npm aliases — pnpm still creates symlinks that Vercel's file tracer doesn't follow.
2. Adding aliased deps explicitly to
package.json— did not fixAdded the aliased packages directly:
Deployed, same error.
3.
nitro.externals.inlinefor@mastra/*— partially workedInlined
@mastra/*packages so the bundler resolves aliases at build time. The error shifted from referencingchunk-SE7ST47S.jstoindex.mjs— inlining partially worked but something still referenced the aliased package name at runtime.Also tried installing the aliased AI SDK deps + inlining them together — still failed.
4.
nitro.noExternals: true— broke the buildSwitched to bundling everything. This broke because
resendoptionally imports@react-email/renderwhich isn't installed. Worked around that withrollupConfig.externalbut the alias issue still wasn't fully resolved.5. Also added
@mastra/schema-compataliased deps — still not enoughDiscovered
@mastra/schema-compatalso uses npm aliases (zod-v3,zod-from-json-schema-v3). Added those too. Still failed — the alias whack-a-mole kept finding new unresolved packages.6. Switching from pnpm to npm — aliases resolved but bundle too large
Removed pnpm entirely and switched to npm. npm's flat
node_modulesresolved all aliases natively, but the resulting Vercel serverless function exceeded the 250MB size limit, so this wasn't viable.7.
shamefully-hoist=true— did not fixReverted to pnpm with
shamefully-hoist=true. Still uses symlinks under the hood, which Vercel's file tracer doesn't follow for aliased packages.8.
node-linker=hoisted— current workaround ✅This tells pnpm to create a flat, non-symlinked
node_moduleslayout (like npm) while still benefiting from pnpm's deduplication, keeping the bundle under Vercel's 250MB limit.Suggestion
The root cause is
@mastra/coredepending on npm aliases for AI SDK packages. This is fragile because:Ideally,
@mastra/corewould avoid npm aliases in its publishedpackage.json, or the Nuxt integration guide and deployment docs would document this requirement. (Note: the web framework deployment page currently covers Next.js and Astro but not Nuxt.)Steps To Reproduce
@mastra/core@^1.24.0node-linker=hoisted)@mastra/corewill crash withERR_MODULE_NOT_FOUNDLink to Minimal Reproducible Example
Workaround in place.
Expected Behavior
Server routes importing @mastra/core should work on Vercel with pnpm's default settings without requiring node-linker=hoisted.
Environment Information
Verification