Error: No router instance found when create a new project using `npx create-next-app`
See original GitHub issueWhat version of Next.js are you using?
11.1.2
What version of Node.js are you using?
14.17.0
What browser are you using?
Chrome, Firefox
What operating system are you using?
Windows 10
How are you deploying your application?
npm run dev
Describe the Bug
When creating a new project using the npx create-next-app <app-name>
command, when executing npm run dev
, a runtime error occurs. Below are the error messages:
First error in router.js:116:14
Uncaught (in promise) Error: No router instance found.
You should only use "next/router" on the client side of your app.
getRouter router.js:116
get router.js:86
_callee$/< on-demand-entries-client.js:47
setupPing on-demand-entries-utils.js:17
_callee$ on-demand-entries-client.js:47
Babel 8
tryCatch
invoke
defineIteratorMethods
asyncGeneratorStep
_next
_asyncToGenerator
_asyncToGenerator
js
Second error in nodeStackFrames.js:40
Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
nodeStackFrames.js:40
getNodeError nodeStackFrames.js:40
_callee$/< index.js:313
Screenshot of browser error:
I tried to reinstall the libraries using the npm install
command, and it kept giving an error. I had to delete the node_modules
folder and reinstall via the npm install
command to fix the error.
I also tried doing the manual installation of Next and didn’t get any errors. Everything worked as it should.
Expected Behavior
I expected the Next default index page.
To Reproduce
Steps to reproduce the error:
- Run
npx create-next-app <app-name>
in command prompt. - Enter to the project
cd <app-name>
. - Run developer server
npm run dev
.
Steps to repare manually:
- Delete file
node_modules
. - Run command
npm install
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
No router instance found. You should only use "next ... - GitHub
Just setup a new Next.js project by fetching next, react and react-dom. Create an index.js page with following code. import Router ...
Read more >Error: No router instance found. You should only use "next ...
Unhandled Runtime Error Error: No router instance found. You should only use "next/router" on the client side of your app. next.js.
Read more >Next.JS Error: No router instance found - Marcusoft.net
So this error even has an page on the Next. JS site and it's helpfully trying to tell me that I'm using the...
Read more >Error: No router instance found. You should only use “next ...
You should only use “next/router” inside the client side of your app. this error it happens when you try to use next/router inside...
Read more >How to Build a Fullstack App with Next.js, Prisma, and ... - Vercel
Navigate into a directory of your choice and run the following command in your terminal to set up a new Next.js project: npx...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @ijjk it worked.
HI, can you try the latest canary of Next.js
v11.1.3-canary.38
, there were some patches made to handling project directories on Windows.