Skip to content

about next.config.mjs in vercel #522

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

Open
allentown521 opened this issue Apr 16, 2025 · 2 comments
Open

about next.config.mjs in vercel #522

allentown521 opened this issue Apr 16, 2025 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@allentown521
Copy link

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

@allentown521 allentown521 added the bug Something isn't working label Apr 16, 2025
@haydenbleasel
Copy link
Owner

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!

@allentown521
Copy link
Author

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?

@haydenbleasel haydenbleasel added the help wanted Extra attention is needed label May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants