Runtime error with latest version of Mastra core

I recently updated to a recent version of @mastra/core 0.23.3 and I get the following error at runtime, which never appeared before:
/app/node_modules/.pnpm/@mastra+core@0.23.3_@sinclair+typebox@0.34.41_encoding@0.1.13_openapi-types@12.1.3_react@19.2_z2dqksn5fjdorsfe3momgu443q/node_modules/@mastra/core/dist/chunk-5KNLBUBH.cjs:97
- Focus on content that could cause real harm
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/.pnpm/@sindresorhus+slugify@2.2.1/node_modules/@sindresorhus/slugify/index.js from /app/node_modules/.pnpm/@mastra+core@0.23.3_@sinclair+typebox@0.34.41_encoding@0.1.13_openapi-types@12.1.3_react@19.2_z2dqksn5fjdorsfe3momgu443q/node_modules/@mastra/core/dist/chunk-5KNLBUBH.cjs not supported.
Instead change the require of index.js in /app/node_modules/.pnpm/@mastra+core@0.23.3_@sinclair+typebox@0.34.41_encoding@0.1.13_openapi-types@12.1.3_react@19.2_z2dqksn5fjdorsfe3momgu443q/node_modules/@mastra/core/dist/chunk-5KNLBUBH.cjs to a dynamic import() which is available in all CommonJS modules.
at Hook.Module.require (/app/node_modules/.pnpm/dd-trace@5.56.0/node_modules/dd-trace/packages/dd-trace/src/ritm.js:97:31)
at Object.<anonymous> (/app/node_modules/.pnpm/@mastra+core@0.23.3_@sinclair+typebox@0.34.41_encoding@0.1.13_openapi-types@12.1.3_react@19.2_z2dqksn5fjdorsfe3momgu443q/node_modules/@mastra/core/dist/chunk-5KNLBUBH.cjs:26:15) {
code: 'ERR_REQUIRE_ESM'
/app/node_modules/.pnpm/@mastra+core@0.23.3_@sinclair+typebox@0.34.41_encoding@0.1.13_openapi-types@12.1.3_react@19.2_z2dqksn5fjdorsfe3momgu443q/node_modules/@mastra/core/dist/chunk-5KNLBUBH.cjs:97
- Focus on content that could cause real harm
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/.pnpm/@sindresorhus+slugify@2.2.1/node_modules/@sindresorhus/slugify/index.js from /app/node_modules/.pnpm/@mastra+core@0.23.3_@sinclair+typebox@0.34.41_encoding@0.1.13_openapi-types@12.1.3_react@19.2_z2dqksn5fjdorsfe3momgu443q/node_modules/@mastra/core/dist/chunk-5KNLBUBH.cjs not supported.
Instead change the require of index.js in /app/node_modules/.pnpm/@mastra+core@0.23.3_@sinclair+typebox@0.34.41_encoding@0.1.13_openapi-types@12.1.3_react@19.2_z2dqksn5fjdorsfe3momgu443q/node_modules/@mastra/core/dist/chunk-5KNLBUBH.cjs to a dynamic import() which is available in all CommonJS modules.
at Hook.Module.require (/app/node_modules/.pnpm/dd-trace@5.56.0/node_modules/dd-trace/packages/dd-trace/src/ritm.js:97:31)
at Object.<anonymous> (/app/node_modules/.pnpm/@mastra+core@0.23.3_@sinclair+typebox@0.34.41_encoding@0.1.13_openapi-types@12.1.3_react@19.2_z2dqksn5fjdorsfe3momgu443q/node_modules/@mastra/core/dist/chunk-5KNLBUBH.cjs:26:15) {
code: 'ERR_REQUIRE_ESM'
The error appears only when I am deploying my application on Koyeb while the local development environment (using a Devcontainer) works just fine. It seems to be related to some issues with slugify. Do you have any idea on how to solve this?
3 Replies
_roamin_
_roamin_•3d ago
Hey @Mario Dagrada ! Could you try upgrading to @mastra/core 0.24.6 and let us know if you're still seeing this issue? We ship a lot of fixes weekly and 0.23.3 is already a month old 😉
Mario Dagrada
Mario DagradaOP•3d ago
Thanks. I updated to 0.24.6 and still get the same issue, unfortunately.
_roamin_
_roamin_•3d ago
Could you try adding @sindresorhus/slugify to your externals, like this?
const mastra = new Mastra({
externals: ["@sindresorhus/slugify"]
})
const mastra = new Mastra({
externals: ["@sindresorhus/slugify"]
})

Did you find this page helpful?