Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError: File not found: /vercel/path0/blog/{WHAT_EVER}.mdx #127

Open
ozgurozalp opened this issue May 19, 2024 · 9 comments
Open

Comments

@ozgurozalp
Copy link

I get this error in vercel FileNotFoundError: File not found: /vercel/path0/blog/{WHAT_EVER}.mdx

FileNotFoundError: File not found: /vercel/path0/blog/gunluk-meditasyonun-faydalari-ve-uygulama-yontemleri.mdx at DirectoryCoordinator.addSourceFileAtPath (/var/task/node_modules/ts-morph/dist/ts-morph.js:19088:19) at Project.addSourceFileAtPath (/var/task/node_modules/ts-morph/dist/ts-morph.js:20551:51) at /var/task/.next/server/chunks/73.js:33:45040 at Array.forEach (<anonymous>) at Q (/var/task/.next/server/chunks/73.js:33:44893) at m (/var/task/.next/server/chunks/73.js:30:36103) at /var/task/.next/server/app/[slug]/page.js:1:4398 { path: '/vercel/path0/blog/gunluk-meditasyonun-faydalari-ve-uygulama-yontemleri.mdx', code: 'ENOENT', page: '/gunluk-meditasyonun-faydalari-ve-uygulama-yontemleri2' }

@souporserious
Copy link
Owner

Assuming the project works locally? Also, what Node.js version are you running in Vercel and is the repo public where I could take a look?

@ozgurozalp
Copy link
Author

ozgurozalp commented May 19, 2024

Assuming the project works locally? Also, what Node.js version are you running in Vercel and is the repo public where I could take a look?

Yes, it works locally.

https://github.com/ozgurozalp/mdxts

@souporserious
Copy link
Owner

Thanks for providing a repo! Sorry, I haven't had a chance to look into this deeper. Are the versions of Node.js locally and in Vercel the same? Off the top of my head, I'm not sure why the TypeScript compiler can't find those specifically in Vercel 🤔

@fluid-design-io
Copy link

fluid-design-io commented Jun 18, 2024

I'm also having this issue, it seems like Next.js automatically "removes" unnecessary files & folders, in this case - the root blog folder once the build process completes. If you go in to one of your development history on Vercel, click on source, then output, there is no original files being preserved.

Btw: you can also build on your local machine and inspect the .next folder, in the server folder, there blog folder only contains the SSG-ed file and paths. Meaning the original files were not included.

I'm still looking for ways to figure out how to solve this issue. In the meantime, use SSG to prebuild your blog pages as static files. Then we need to "ignore" allBlog.get() method on Vercel so it won't cause error (as all pages are now static).

@fluid-design-io
Copy link

I'm also having this issue, it seems like Next.js automatically "removes" unnecessary files & folders, in this case - the root blog folder once the build process completes. If you go in to one of your development history on Vercel, click on source, then output, there is no original files being preserved.

Btw: you can also build on your local machine and inspect the .next folder, in the server folder, there blog folder only contains the SSG-ed file and paths. Meaning the original files were not included.

I'm still looking for ways to figure out how to solve this issue. In the meantime, use SSG to prebuild your blog pages as static files. Then we need to "ignore" allBlog.get() method on Vercel so it won't cause error (as all pages are now static).

Update:

I moved the root blog folder into app/ folder and renamed it as _blog. Then I changed the config as follows:

before:

import { createSource } from "mdxts";

export const allBlog = createSource("**/*.mdx", {
  baseDirectory: "blog",
  basePathname: "/blog",
  sort: (a, b) => b.frontMatter.date.localeCompare(a.frontMatter.date),
});

After:

import { createSource } from "mdxts";

export const allBlog = createSource("**/*.mdx", {
  baseDirectory: "_blog", // <-- Change this
  basePathname: "/blog",
  sort: (a, b) => b.frontMatter.date.localeCompare(a.frontMatter.date),
});

I have not seeing Vercel log errors ✨

Can you try if this helps?

@souporserious
Copy link
Owner

@fluid-design-io thank you for looking into this! This makes much more sense now, I didn't realize this happened when it wasn't static. This might be fixed by specifying the directory with outputFileTracingRoot in your next config.

@hipstersmoothie
Copy link
Contributor

I'm hitting the issue in a similar fashion. Problem basically being: the library expects all files to be there but they aren't. No way of fiddling with the options seems to work or include any of the files

@hipstersmoothie
Copy link
Contributor

I feel like ultimately the way renoun is interaction with bundlers isn't sufficient right now. It seems like fs apis are being used, which go outside a bundler, and make deploying with next a real pain.

@souporserious
Copy link
Owner

@hipstersmoothie what version are you on? Assuming you are targeting files outside of the workspace? I still haven't run into this personally. Not sure why it hasn't been an issue for me. In Vercel's project settings I have this option checked:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants