about next.config.mjs in vercel
Describe the bug I want to use fumadocs , and according to its documentation, I can only use next.config.mjs, so I modified the next.config.ts of apps/web to mjs, but directly refer to feature-flags/lib/toolbar, I get the following error:
⨯ Failed to load next.config.mjs, see more info here https://nextjs.org/docs/messages/next-config-error
Build error occurred [Error: Cannot find module '/packages/feature-flags/lib/toolbar' imported from /apps/web/next.config.mjs] { code: 'ERR_MODULE_NOT_FOUND', url: 'file://packages/feature-flags/lib/toolbar'
So I modified it to: feature-flags/lib/toolbar.ts, which works well locally, and when I try to deploy to vercel, I get an error:
⨯ Failed to load next.config.mjs, see more info here https://nextjs.org/docs/messages/next-config-error web:build: web:build: > Build error occurred web:build: TypeError: Unknown file extension ".ts" for /vercel/path0/packages/feature-flags/lib/toolbar.ts web:build: at Object.getFileProtocolModuleFormat [as (file:] (node:internal/modules/esm/get_format:219:9) { web:build: code: 'ERR_UNKNOWN_FILE_EXTENSION'
next-forge version I am using version 4.2.6
Hey @allentown521, I'm familiar with the issue - that's difficult 😞
Basically it's erroring because .mjs files can't import .ts files easily, but I'm aware that Fumadocs needs .mjs to function.
I think you may need to find all the files that your new next.config.mjs file imports (like packages/feature-flags/lib/toolbar and rework them to .mjs as well.
Let me know how you go!
I guess this is a solution, but it's destructive, maybe they should be mjs files, and other similar products use mjs, in addition to fumadocs.
But what puzzles me is why my local build is normal and only has this problem when deployed to vercel. Can we try to solve this problem from this perspective?