-
Notifications
You must be signed in to change notification settings - Fork 36
Next build fails with empty .mdx-data folder #45
Comments
Large reproducible example -> leerob/leerob.io#159 After bringing that down to the absolute minimum working example, which I had originally started with, I started to piece it back together. By the process of elimination of deleting code and modules, I found the smoking gun to be Firebase. I think by adding that dependency it's bumping some Babel things, which is breaking this. Here is the absolute bare minimum reproducible example. First commit is in a working state, second commit the build fails after adding firebase as a dependency. |
This seems related -> vercel/next.js#296. Maybe the JSON file isn't available on the server, which is why then once |
@leerob hey Lee! I'm not actually a maintainer but I've just hit a similar issue to you. My solution was a quick flush of the build directories: rm -rf .next out .mdx-data |
@joe-bell My bad, thanks for chiming in, though! I believe this issue is the exact opposite of that one. The root problem is the |
This isn't the greatest workaround, but it works. I just run the build script twice 🤷♂
|
I'm also hitting this, causing my "zeit now" deployments to fail. 11:20:06.612 Module not found: Can't resolve '/zeit/4756b631/.mdx-data/030ee89fb6f7f9ddf334677dba207de9.json' in '/zeit/4756b631/src/layouts' I'd hate double my build-time to work around this bug, but I guess it's better than broken deployments... |
Hi! I'm so sorry I was behind on notifications and just seeing this message. The error messages I am seeing above, I do not think are happening because the Thanks so much for providing that repro though, this is a life saver. I'm going to take a look and get back to you all here. Sorry again for the late response! |
Confirmed there's an issue here, working on tracking it down. It may have been some changes to webpack? When I run this, the file that it says is not present does seem to be present, and all the file writes are set to happen before any nextjs processing begins, so I'm confused by how this is possible. |
@jescalan No worries at all, thrilled you're willing to take a look. I appreciate all the hard work that went into this library. It's been a lifesaver for me! |
That was my hunch as well. Very strange. I tried to look at the |
Ok @leerob I think I have tracked down the issue here, it was pretty nasty. The root problem is that the layout file was not returning the right thing. Layouts need to return a function, the way it shows in the readme for this repo and for mdx itself. This is not at all intuitive and I can't blame you for missing this though, so I do think I should probably make sure this library looks for the export format of the layout and flags it with a more clear error when this type of thing happens. Changing the layout file in your repro to the following:
...then clearing the The error above was coming up not because it was the actual error, but because of a strange babel caching problem. Clearing the cache entirely and running a fresh build would turn up an alternate error straight out of react that eventually led me back to the layout problem. I think overall the lesson here is that I need to be stronger in my recommendation that using this plugin means clearing the babel cache on build. There are a variety of babel cache issues that root from the unusual nature of the babel plugin manipulation we need to do to make this work, and its dependence on filesystem changes (more detail in this issue). If it makes any difference, I modded Before I take this on myself, want to open up the opportunity to add the enhanced "layout return format mistake" error message to the library via PR if anyone here is interested in contributing. If I get no bites, I'll add something in here maybe later this week. While I'm here want to also mention that we are cooking up an alternative to this library that we are pretty excited by, and there will be more info on this soon 😀 |
I'm still seeing the issue after switching the layout to this:
Are you not seeing that? |
Hmm, I changed a few other things as well and dropped a bunch of unused dependencies in the debugging process, this was the step that ultimately did it. Let me clone a fresh copy and try again |
@leerob it was indeed some of my dependency changes, pretty crazy. I'm not sure which dependency it was that was causing the interference, but stripping out unneeded dependencies is giving me a clean build, where with the dependencies you originally had listed, I was seeing the error. I made a PR to your reproduction repo with my changes - hopefully this helps! |
Hey hey, going to close this one out as I haven't heard anything back. Let me know if there's anything that still needs to be addressed here and I'd be happy to re-open! |
Hi @jescalan I can confirm the same issue as @leerob. See my repo for reproduction: https://github.com/QuanTumli/mdx-enhanced-issue
(Project was initialized with Steps to reproduce the error:
The |
Sorry for my slow response! While your PR did have a fix, as soon as I added back the dependencies, I saw the same error as before. Going back to my initial message, that was why I pinned down updating Firebase specifically that seemed to mess it up. |
I'm hitting the same issue (see CI build), something interesting is that the "missing" JSON file does exist in The issue seems to come from the front matter import feature:
|
Confirming this as well -- clean build locally & on However, I have found that if I specify the exact version in "dependencies": {
...
"next": "9.4.0",
"next-mdx-enhanced": "3.0.0",
...
} |
Pinning Edit: it has more to do with regenerating the lockfile than pinning the version, when changing it back to |
I'm seeing the same issue as @franky47 . I can get local version building correctly after removing local cached folders, but rebuilding from clear cache on Netlify still produces clean build error. |
I also get a race-condition kind of error, which does not happen all the time, and could be related to this issue:
Looks like the JSON file is being written while Next.js/Webpack is trying to load it. This happens on non-clean builds, and it takes up to 4 or 5 retries to get the build to pass sometimes. |
Getting the similar to @franky47's error:
I tried these hacks:
|
FWIW I’m experiencing this issue as well on my site’s repo. I hated the idea of always running the build step twice so changed the build step to |
This should be resolved by the latest release! |
Hey, sorry I didn't report it back sooner, but yes the issue has been solved for a few weeks in my case. Thanks ! |
Interesting enough, version 5.0.0 does not fix the issue for me 😔 NotesI have to be clear on a number of things though:
Findings
import { frontMatter as blogPosts } from 'pages/posts/**/*.mdx';
event - build page: /blog
wait - compiling...
error - ./pages/blog.js
Module not found: Can't resolve '/Users/ivan/Projects/personal/ivan-website/.next/cache/mdx-data/85a9f12bff72bcf2394b051245538228.json' in '/Users/ivan/Projects/personal/ivan-website/pages'
event - compiled successfully My project has a number of dependencies, played a bit with some of them but can't really tell anything did any difference. |
@ivannovazzi - the 5.0 release does not use If you can make me a minimal reproduction of the issue here I would be happy to look! |
@jescalan well, the folder is moved under .next/cache and the same exact behaviour is observed. I will put together a minimal reproducible scenario asap. |
Thanks so much @ivannovazzi - looking forward to it! |
My apologies @jescalan , the plugin is behaving perfectly and congrats for building this! In case someone else runs into this exact issue, the import shown above was causing troubles because of the missing babel plugin I should have smelled something was wrong on my end since I had noticed the |
Thats great to hear - so glad you figured it out! |
Hey! Love the project. Trying to convert my MDX blog over to this. Hit a snag while trying to deploy. I'm seeing this error when I run
next build
.If I then immediately retry the build, it works as expected. Any idea what this could be? It seems like if the
.mdx-data
folder does not exist at all (which is what happens when I try to deploy) then it errors out.I can try and get a reproducible example up if that would be helpful.
The text was updated successfully, but these errors were encountered: