webpack: TypeError: Cannot read property 'jsonData' of undefined
Please excuse that the bug report is quite short. I don’t have time to debug the problem myself today. Since the bug doesn’t come from other dependencies according to the stacktrace and the only change since the last usage is in the webpack version, I post the bug report anyway.
Bug report
What is the current behavior?
The build process crashes when watching for changes. The first build works fine, on saving a file, the process throws the folloging error.
let data = module.buildInfo.jsonData;
^
TypeError: Cannot read property 'jsonData' of undefined
at JsonGenerator.getSize (./node_modules/webpack/lib/json/JsonGenerator.js:119:31)
at NormalModule.size (./node_modules/webpack/lib/NormalModule.js:1224:43)
at NormalModule.cleanupForCache (./node_modules/webpack/lib/NormalModule.js:364:9)
at NormalModuleFactory.cleanupForCache (./node_modules/webpack/lib/NormalModuleFactory.js:670:11)
at Compiler._cleanupLastNormalModuleFactory (./node_modules/webpack/lib/Compiler.js:383:34)
at Compiler.createNormalModuleFactory (./node_modules/webpack/lib/Compiler.js:1049:8)
at Compiler.newCompilationParams (./node_modules/webpack/lib/Compiler.js:1071:30)
at Compiler.compile (./node_modules/webpack/lib/Compiler.js:1082:23)
at ./node_modules/webpack/lib/Watching.js:188:19
at Hook.eval [as callAsync] (eval at create (./node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
If the current behavior is a bug, please provide the steps to reproduce.
I will update the instructions to reproduce the error next week if necessary.
What is the expected behavior?
module.buildInfo
seems to be undefined, although it shouldn’t be. When I replace the line with let data = module?.buildInfo?.jsonData;
it works fine but I don’t think this would be a good solution.
Other relevant information: webpack version: 5.42.0 throws the error. 5.41.0 seems to be working Node.js version: v16.4.0, v12.x of my coworker didn’t work aswell Operating System: Windows Additional tools: Custom CLI with embedded webpack.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 31
- Comments: 20 (5 by maintainers)
Commits related to this issue
- fixes #13691 — committed to webpack/webpack by sokra 3 years ago
- Merge pull request #13708 from webpack/bugfix/crash-unsafe-cache fixes #13691 — committed to webpack/webpack by sokra 3 years ago
- downgrade webpack to fix https://github.com/webpack/webpack/issues/13691 — committed to luomus/laji-form by olzraiti 3 years ago
We will fix it in near future, sorry
Critical
While waiting…
I did a little
package.json
hack to force an older webpack version:Then run
npm i
I had this problem just now, deps. is
“@pmmmwh/react-refresh-webpack-plugin”: “^0.4.3”, “react-refresh”: “^0.10.0”, “webpack”: “^5.42.0”, “webpack-dev-server”: “^3.11.2”,
simple page is work fine , but when real project building process will crashes.
first building is work fine , second time is crashed
node -v
): v14.17.0npm -v
): 6.14.13I’m having this bug, too. Here are some information from my side. Maybe it helps to find the issue. This is the error I get, when it happens:
This is the content of the file
2021-07-04T19_15_00_411Z-debug.log
:Actually it happens every second edit of my code.
@raduchiriac @dgb23 This worked. I don’t have a webpack.config.js for Storybook, but I made an entry in main.js in the webpackFinal method setting config.cache = false; And it works. Thanks for this. I spent a lot of time trying various suggestions and only this one worked.
Running into the same issue, switching to 5.41.0 doesn’t resolve issue.
node version v12.x Operating System: osx
Works when building to a system module directly from webpack compiler, but fails in fresh storybook running webpack 5
This worked. Thanks @dgb23 & @TerrySlack
.storybook/main.js
@alexander-akait There is my reproduction repo for the issue.
I managed to narrow down the bug to using only one external package
ajv
with a specific version