ERR_MODULE_NOT_FOUND when running `mastra dev`
Hey folks,
Have recently started getting the above when running
mastra dev. We didn't get it before, and we think it's because the @cubejs-client/core package doesn't have file extensions on its imports. We run Mastra in Next with mastra dev --dir src/mastra. Any way around this one?
It worked previously, so not sure if you've made any bundler changes.17 Replies
Have tried changing
"type": "module" in package.json, and running with -c '--experimental-specifier-resolution=node'š Created GitHub issue: https://github.com/mastra-ai/mastra/issues/8297
GitHub
[DISCORD:1422529954025046096] ERR_MODULE_NOT_FOUND when running `ma...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1422529954025046096 Hey folks, Have recently started getting the above when running mastra dev. We didn...
Hi @Isaac Harris-Holt ! Could you share the full error message you're getting?
Sure!
The head of
index.js in the Cube package is:
I think this is what's causing the issue, but it was working previously with the same version of CubeThere have been a few updates to our bundler. Could you try adding Cube to the transpile packages bundler config:
No dice, I'm afraid. Cube only ship the compiled JS, if that matters
Adding to
externals doesn't work either
(I have no idea what I'm doing - just trying stuff)I see, thanks for testing! Would you mind sharing a small repro example? Is it just adding the Cube package to a Mastra project?
Let me check
Works with a fresh installation. I've got a call now, then I'll try with a Next one
I scaffolded a fresh Next app and used the one liner, and I just get the following:
Then the process exits. I've not installed cube yet
Okay @Romain turns out I'm an idiot. A fresh Mastra install with the following in the index file gives the error:
I'd forgotten to actually import the library previously š
Don't worry, we're all idiots š
Thanks, I can repro, too!
I'll add the code you shared to the github issue
I added a note to the issue (https://github.com/mastra-ai/mastra/issues/8297#issuecomment-3388803351) to tell you how to workaround this bug in cubejs
GitHub
[DISCORD:1422529954025046096] ERR_MODULE_NOT_FOUND when running `ma...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1422529954025046096 Hey folks, Have recently started getting the above when running mastra dev. We didn...
What about other modules? Am I going to have to do the same if I run into the same issues elsewhere?
Yes, if the module is invalid it needs to be fixed upstream
That's not always feasible. Some of the libraries that'll be causing this problem may take months to get to an issue, especially something as large as migrating to ESM. I appreciate it's extra work for you folks, but it's making the Mastra playground unusable when pulling in dependencies that haven't made the switch
Cube, in particular, is something that'll be used by a large number of folks working with agents
It's not about libraries switching to ESM, Mastra supports CommonJS packages just fine. It's that the ESM version of CubeJS is invalid. Then when Mastra tries to just run
node index.mjs with the cubejs import, it fails
But let me double check internally if transpilePackages couldn't handle this alternativelyThanks š It worked previously, so it should be able to
We spent some time looking at it today but it's not an easy fix. And with other priorities not high on our list of things to fix (since it's the fault of an upstream package). So can't give you an ETA when that might be fixed
Alrighty, no worries. Thanks for taking a look