next.js: Invalid HMR message..Error: No router instance found. ???
What version of Next.js are you using?
12.0.1
What version of Node.js are you using?
17.0.1
What browser are you using?
Chrome / Safari
What operating system are you using?
macOS
How are you deploying your application?
dev
Describe the Bug
While loading in locally developed npm packages, I get a weird warning in the console:
[Warning] Invalid HMR message: {"action":"sync","hash":"","warnings":[],"errors":[]} Error: No router instance found. You should only use "next/router" on the client side of your app.
This current app is a test app that has no router instance anywhere, its just one page so the error doesn’t really make sense. The npm package is adding styles to the _app.tsx (global style) and an Icon component to the index.tsx file.
Chrome gives the same warning only on initial load but the warning goes away after that
Expected Behavior
The expected behaviour would be no hmr warning
To Reproduce
Not sure how others can reproduce the error since its kinda random
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 52
- Comments: 42 (6 by maintainers)
Its also strange cause I am not actually using the router at all in my test app 😕 like not once is useRouter called in the entire application…
I am facing the same issue.
Hi, another case where this message could occur has been updated in
v12.0.5-canary.8
of Next.js, please update and confirm whether this issue is still present.@ijjk console.warning is gone 😃 thx for the super fast and dedicated patch work, super appreciated 🏆
@ijjk issue is persisting 😕
I am facing the same issue. Even I comment all components in the index. And I never use “useRouter” in my project. This is really weird.
For me, this is happening to the only page that doesn’t use
useRouter()
after hard refresh on the page.I have a slightly different error message but it seems similar. It happens only on AMP pages :
export const config = { amp: true }
Edit (add versions): Node: 14.17.3 Next : 12.0.2 Browser: Chrome OS: Linux
I started running into the same issues tonight, and what was happening is this error appeared in my browser console, but I was also hitting server errors where it could not read my GraphQL schema. I just downgraded to
next@12.0.0
(prev.next@12.0.2
) and my site is working again.Can confirm. Issue still present on
12.0.5-canary.4
This is also true for me. Next 12.0.2 Tailwindcss 2.2.19 Node 16.13.0 Mac OS 12.0 Chrome 96.0.4664.45
Same. Using this framework is becoming a full-time job. The last upgrade trashed images loading times…
Using 12.0 got rid of that error and surfaced another:
Module not found: ESM packages (./_root.js) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals
.This gets rid of it:
Then it’s trashed by another error…