-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
Dev mode on Next.js v12 breaks with combination of features #30330
Comments
We're having a look at the reproduction! |
This comment has been minimized.
This comment has been minimized.
I encountered something very similar on a private project. I haven't put together a separate reproduction yet, but I checked and it has exactly the same versions of each external dependency in the reproduction in this issue. |
This comment has been minimized.
This comment has been minimized.
@sokra is investigating this. Please don't post OOM messages in this thread until we post a reply here as they're not useful for investigating the issue and will ping everyone subscribed. If you want to provide a reproduction feel free to post repositories. Just to verify you're all using |
@timneutkens, same error here. I am not using pnpm, only common packages that I use are To reproduce this error, I started 2 new project by doing |
Okay thanks @mustaphaturhan! |
This seems to be a particular case with Chakra UI and some other deps. module.exports = {
experimental: {
esmExternals: false
}
} |
To anyone who isn't sure where to add the module exports stated above as a temporary fix, you can refer to next.config.js |
@sokra, this error also happens when I install one of this packages: |
Had the same issue, increased memory, completely re-installed all node related stuff and that didn't helped. Then I've just removed the |
I'm using Chakra UI too and this work around saved me. |
Same happening here with Chakra. Seems like it was enabled by default in |
Same happening here with Chakra. |
@timneutkens Since 12.0.1 was released without a fix for this the milestone has to be changed? I updated the reproduction repo Next.js version to 12.0.1 and the same issue is still there (the workaround of |
Chakra UI Contributor here. Anything we can do on our side? @timneutkens |
Chakra user here, it also happens to us with Next 12.0.1; in our case, it also happens when trying |
fix in on the way. Here a little explanation what happend here: Usually Next.js will not bundle node_modules in the server compiler. It will make them "external" and either But that sadly bundling the package also doesn't work correctly in combination with other nested package being made externals. I think it has something to do with async modules and circular dependencies, but I'm still investigating. Actually it shouldn't run into that case anyway. The fix is that Next.js now detects that case and tries to fallback to the CJS version of the package first, before falling back to bundling the package.
Yes. Please add a You can try to import your packages via Node.js to check if they are valid:
In addition to that file extensions are mandatory in Node.js ESM: https://nodejs.org/api/esm.html#mandatory-file-extensions -export * from "./chakra-provider";
+export * from "./chakra-provider.js";
-export * from "./extend-theme";
+export * from "./extend-theme.js";
-export * from "./theme-extensions";
+export * from "./theme-extensions.js"; |
I was not able to reproduce it with these packages, but at least for the |
@sokra From their documentation: |
I will do that for the client-side, but on server-side it tries to run packages unbundled. Running unbundled means you are subject to Node.js EcmaScript implementation: https://nodejs.org/api/esm.html |
fallback to alternative external version also when it fails because of base resolve mismatch# fix resolved .mjs modules treated as external fixes #30330
I'm using Github actions to deploy my app with serverless-nextjs, it's working locally but on deploy environment get |
I'm experiencing the same issue while trying to deploy on Firebase hosting & functions. The I've pretty much tried everything on Github issues referenced above. |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
fallback to alternative external version also when it fails because of base resolve mismatch# fix resolved .mjs modules treated as external fixes vercel#30330
What version of Next.js are you using?
12.0.0 and 12.0.1
What version of Node.js are you using?
v16.13.0 and v14.18.1 and v12.22.7
What browser are you using?
Doesn't apply, breaks on terminal
What operating system are you using?
Arch Linux and macOS Big Sur 11.6
How are you deploying your application?
next dev
Describe the Bug
next dev
breaks on v12, but I'm not exactly sure why, I was able to create a minimal reproduction repo with a combination of features, but I tried reproducing the issue with almost every feature (externalDir, chakra-ui, monorepo, typescript of course) of the repository by itself and worked fine, so I'm not completely sure what breaks itExpected Behavior
dev mode should work??, in v11 everything works fine
To Reproduce
https://github.com/PabloSzx/next-v12-bug
The text was updated successfully, but these errors were encountered: