Next.js "invariant expected layout router to be mounted" error after restarting dev — no changes made #166699
Replies: 2 comments 2 replies
-
|
Hye @hendrixejegi, |
Beta Was this translation helpful? Give feedback.
-
|
Start by clearing the cache: rm -rf .next
npm run devIf that doesn't fix it, the fact that it works on a fresh Next 14 scaffold but breaks after upgrading to 15 is the real clue. Next.js 15 ships with React 19 by default, and if your Check what's actually installed: node -e "const p = require('./node_modules/react/package.json'); console.log(p.version)"
node -e "const p = require('./node_modules/react-dom/package.json'); console.log(p.version)"If they're mismatched, upgrade both: npm install react@latest react-dom@latestOr if you want to stay on React 18: npm install react@18 react-dom@18 --legacy-peer-depsOne more thing to check: if you're using |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Body
I’m working on a Next.js project using the App Router. Everything was working fine — I made changes, committed the code, shut down my machine.
Came back the next day, ran
npm run dev, and immediately got this error:No changes were made between when it was working and when it broke.
Has anyone else experienced this after a clean shutdown/restart? How did you resolve it?
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions