`next build` fails with webpack error
See original GitHub issueWhat version of Next.js are you using?
10.2.1
What version of Node.js are you using?
14.16.0
What browser are you using?
n/a
What operating system are you using?
MacOS, Linux
How are you deploying your application?
AWS
Describe the Bug
When attempting to do a build with next build I get the following error. With next 10.2.0, the error does not appear.
info - Checking validity of types
info - Using external babel configuration from /var/www/sites/customer-ui/.babelrc.js
info - Creating an optimized production build
Failed to compile.
chunk webpack [entry]
Cannot read property 'asString' of undefined
> Build error occurred
Error: > Build failed because of webpack errors
at /var/www/sites/customer-ui/node_modules/next/dist/build/index.js:17:924
at async Span.traceAsyncFn (/var/www/sites/customer-ui/node_modules/next/dist/telemetry/trace/trace.js:6:584)
Oddly enough, this doesn’t happen when running the build on MacOS…it only occurs when running in our node:14.15.0-alpine docker container.
Expected Behavior
A clean build.
To Reproduce
next build
I’m unsure what to provide to reproduce the error. The message doesn’t give a good indication of where the problem exists or what I might do to provide a minimal project that exercises the issue.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:30
- Comments:25 (7 by maintainers)
Top Results From Across the Web
nextJS build fails on Vercel because of Webpack errors
I got help from support, it seems that even though my local components are Capitalized the remote branch had some components lowercased.
Read more >Next.js build is failing - Render community
My Nextjs build keeps failing, although it works fine locally. My error logging shows the following: Jun 22 05:07:47 PM > Build error...
Read more >Next.js deploy fails on webpack build - Netlify Support Forums
This suggests to me that while the version number hasn't changed, something in the code has. It also appears some dependencies in your...
Read more >Build Failure Because of Webpack Errors - Sanity.io
pages/index.js11 :33: 35.355Module not found: Can't resolve '@sanity/client' in '/vercel/path0/pages' Build failed because of webpack ...
Read more >Build Failed - Web App - Build issue - AppGyver forums
“FAILED with ERROR: │ [ error ] [build] COMMAND: npx next build FAILED with ERROR: > Build failed because of webpack errors Command...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This problem can be solved by adding
future: { webpack5: true }to next.config.js and enabling webpack5. Probably a compatibility issue between webpack4 and webpack5.@timneutkens Hi check this repo https://github.com/SinimaWath/next-dynamic-css
That bug appears only with dynamic Components in project.
Edit: And it seems because of this PR https://github.com/vercel/next.js/pull/24573/files @sokra.
Without CSS in dynamic chunks, build works fine