-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Next.js 14.0.3 fails to build when using antd
due to "SyntaxError: Cannot use import statement outside a module"
#58817
Comments
+1 |
1 similar comment
This comment has been minimized.
This comment has been minimized.
I had the same issue during an upgrade. I've solved the issue by using the These were the required changes for my project, all |
@CatalinScaesteanu Hi, I tried this but still get the error. Did you change anything else? |
There seems to be a PR to fix this: #58992 |
I tried this and it worked for me! However I had to update the list because we apparently use different ant components :) This is the full list needed:
|
Nice one |
You saved my life!! |
I had the same issue and it has been fixed by adding this to the next.config.js.Thanks. |
* fix(deps): update dependency next to v14 * fix(nextjs): rectify antd-related modularize imports See vercel/next.js#40183 and vercel/next.js#58817. --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: sabertazimi <sabertazimi@gmail.com>
Closing this as the issue is fixed in the nextjs versions same as or above 14.0.4 |
Hi, @huozhi In my project can't update NextJS to any version after
|
|
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://github.com/victorandree/next.js14.0.3-antd4-reproduction
To Reproduce
<Spin />
)Note: This issue exists both with
antd@4
andantd@5
. However, I originally discovered and reproduced the issue withantd@4
, because my organization is still using this version. The reproduction usesantd@4
, but updating toantd@5.11.3
(the latest version as of Nov 23, 2023) still causes the same issue.Current vs. Expected behavior
The build will fail with an error message like the following:
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.6.0: Wed Oct 4 21:26:23 PDT 2023; root:xnu-8796.141.3.701.17~4/RELEASE_ARM64_T6000 Binaries: Node: 20.5.1 npm: 9.8.0 Yarn: N/A pnpm: N/A Relevant Packages: next: 14.0.4-canary.11 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
SWC transpilation
Additional context
I am 99% sure that this is caused by #57968, as that PR changed
antd
imports toes
fromlib
, presumably without also making sure these files are transpiled correctly.The text was updated successfully, but these errors were encountered: