next.js: Cannot read property 'pop' of undefined
Bug report
Describe the bug
next build failed after upgrade to 9.2.0
Failed to compile.
chunk commons [initial]
static/chunks/commons.c26e165c.chunk.css
Cannot read property 'pop' of undefined
> Build error occurred
Error: > Build failed because of webpack errors
at build (/home/ubuntu/app/node_modules/next/dist/build/index.js:10:900)
at <anonymous>
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Expected behavior
Build success
System information
- OS: Ubuntu 18
- Version of Next.js: 9.2.0
- Node: 8.12.0
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 41 (16 by maintainers)
node v10.16.0 - the same error node v12.12.0 - the same error
only thing that helped is adding
in my next.config.js
I found the solution by combine the solution with this comment: https://github.com/webpack-contrib/mini-css-extract-plugin/issues/341#issuecomment-675603278
In my next.config.js under webpack(config)
I hope this will solve issue for whoever runs into it.
Addressing the issue now. Will update both threads
Hi,every body, I solved this question by here , in this way, you need to found node_modules/mini-css-extract-plugin/dist/index.js line 341
add this line in there
Hello everyone. We’ve managed to create a minimal reproducible demo of this bug with a closed-source example graciously provided by someone. 🙏
We’ve narrowed the issue down to
extract-css-chunks-webpack-plugin, specifically, this line.This plugin appears to not account for an edge-case webpack produces under our new chunking configuration. The minimal reproducible demo is to import CSS in
pages/_app.jsand then also a component that’s imported usingimport()(ornext/dynamic).For reference, the same code that errors with
extract-css-chunks-webpack-pluginworks with Next.js’ new built-in CSS support (which usesmini-css-extract-plugin).We will file a bug with
extract-css-chunks-webpack-pluginon behalf of the community!Unfortunately, since this is not a bug with Next.js, there are no instructions we can give to fix this until it’s resolved upstream.
Reduced reproduction: https://github.com/Timer/extract-css-chunks-webpack-plugin-bug
Both Node 8 and 9 are no longer supported (not by Next.js, but in general). They reached their official end of life. Please try using Node 10, 12 or 13.
I got the
Cannot read property 'pop' of undefinederror in the latest version of NextJS in a random component 🤔any news about this?
this line surely fixed the problem, my node’s version is v10.15.3
I’m adding additional lines
commons.enforcesolve my issues.
@Timer We also have this error in our project (next.js 9.3.6, without extract-css-chunks-webpack-plugin). The problem arises using dynamic imports. I couldn’t figure out the details, but error disappeared when I changed import of one of component from dynamic to default. View https://github.com/webpack-contrib/mini-css-extract-plugin/issues/341
@Timer i did research, based on your bug showcase branch, and posted what i found in mini-css-extract-plugin issue, that discuss dynamic imports - https://github.com/webpack-contrib/mini-css-extract-plugin/issues/341#issuecomment-594540353
My PR #10171 has been closed so let’s continue discussion here. Unfortunately, I can’t provide reproducible demo for the moment. Error happened in big private project. We use styled components there but tried to work with css-modules as better solution. I’ll try to reproduce error in small synthetic project and let you know in case I catch it.
Anyway, thank you for such a great tool. We’re very happy by using it.