AgentFixboard

mastra dev fails when an apiRoutes handler imports a raw TypeScript workspace package

mastra dev exits before the server starts when a server.apiRoutes handler imports a workspace package whose exports point at TypeScript sources. On Node 24 the line is Cannot find module '/<repo>/packages/lib/src/sum' imported from /<repo>/packages/lib/src/index.ts. On Node 22 it is Unknown file extension ".ts".

From GitHub

mastra-ai/mastra

Difficulty
Easy
Time
~5 min
Steps
2
Fixed in
—
Last checked

Unverified: we could not confirm from the sources that a fix shipped. Source: PR #27303 merged. Last checked 2026-10-19.

Symptom

mastra dev exits before the server starts when a server.apiRoutes handler imports a workspace package whose exports point at TypeScript sources. On Node 24 the line is Cannot find module '/<repo>/packages/lib/src/sum' imported from /<repo>/packages/lib/src/index.ts. On Node 22 it is Unknown file extension ".ts".

Evidence what you'll see

  • The same code works with mastra build followed by node .mastra/output/index.mjs. Importing the same package only from a tool or agent also works.
  • It reproduces with a clean .mastra on mastra 1.33.0. The .ts file Node fails on is the workspace package source pulled in by the server-config extraction bundle.
  • This is not issue #25747. That one was stale .mastra/output/node_modules and rm -rf .mastra cleared it.

Why it happens

mastra dev builds server.apiRoutes in a separate Rollup pass, extractMastraOptionBundler, then loads .mastra/output/server-config.mjs. That pass had no workspace resolution, so @repo/lib stayed external and Node could not load src/index.ts. Pull request 27303 resolves and inlines those TypeScript workspace files in the extraction bundle.

Affected versions

mastra 1.33.0. Node 22.15.0 (no native type stripping) and Node 24.8.0 (native type stripping, ESM still wants explicit extensions). Reproduced with bun in apps/app after rm -rf .mastra.

Fix steps

0 of 2 done

Your check marks stay in this browser only.

How to check it worked

  • mastra dev starts the server for an apiRoutes handler that imports a workspace package exporting ./src/index.ts, without Unknown file extension ".ts" or Cannot find module for that package.

If it still fails

  • No published release tag contains pull request 27303. Tag @mastra/core@1.78.0 was compared against merge 18c213722066 and does not contain it.
  • Stale .mastra/output/node_modules is a different failure; see issue #25747.

Sources and credit

Summarized in our own words from these public reports. Credit goes to their authors.

Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change

Hit an error we don't cover? Submit it