1 minute read | 3 months ago
When I was deploying a NextJS project to Vercel that involved reading local files. Upon reading a file, I encountered the following error message(s).
After almost 3 days of debugging and research, I came to realize that "There are some cases in which Next.js might fail to include required files, or might incorrectly include unused files. In those cases, you can leverage outputFileTracingExcludes and outputFileTracingIncludes respectively in next.config.js. Each config accepts an object with minimatch globs for the key to match specific pages and a value of an array with globs relative to the project's root to either include or exclude in the trace." Upon realizing this, I updated my next.config.js file to include my files/folders, and everything worked fine.
It is also worth mentioning that, in dev, this problem does not happen, it only happens in prod. Reference: Output