AgentFixboard

mastra dev drops workspace-package exports that only tool files import

mastra dev fails at boot when a file under src/mastra/tools/ imports a name from a workspace package that the entry file does not import. The line is SyntaxError: The requested module '…/node_modules/.cache/<pkg>.mjs' does not provide an export named 'X'.

From GitHub

mastra-ai/mastra

Difficulty
Easy
Time
~5 min
Steps
2
Fixed in
@mastra/core@1.78.0
Last checked

Verified fix: PR #27132 merged on . Fixed in @mastra/core@1.78.0 (first published release whose tag contains the merge commit). Last checked .

Symptom

mastra dev fails at boot when a file under src/mastra/tools/ imports a name from a workspace package that the entry file does not import. The line is SyntaxError: The requested module '…/node_modules/.cache/<pkg>.mjs' does not provide an export named 'X'.

Evidence what you'll see

  • DevBundler.watch() analyzed [entryFile, <#server stub>]. Workspace-package bundles then exported only the names that analysis saw.
  • mastra build includes resolved tool paths in analyzeBundle(), so build works and dev does not. --tools cannot work around it because getAllToolPaths() always adds the default glob.
  • The pull request's reproduction printed SyntaxError: The requested module '.../.mastra/.build/shared.mjs' does not provide an export named 'B'.

Why it happens

Tool files are not reachable from the Mastra entry, so their workspace-package imports were dropped from the dev bundle. Pull request 27132 resolves tool paths before building the watcher options and adds them to analysisEntries.

Affected versions

mastra 1.31.3 through 1.34.1. Reproduced in a monorepo where the entry imports one export and a src/mastra/tools/ file imports another.

Fix steps

0 of 2 done

Your check marks stay in this browser only.

How to check it worked

  • mastra dev boots when the entry imports A and a tool file imports B from the same workspace package, without does not provide an export named 'B'.

If it still fails

  • The linked issue does not describe the missing-export boot failure after a tree that contains pull request 27132. Tag @mastra/core@1.77.0 is earlier than that merge.

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