question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: No router instance found when create a new project using `npx create-next-app`

See original GitHub issue

What 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: bug

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:

  1. Run npx create-next-app <app-name> in command prompt.
  2. Enter to the project cd <app-name>.
  3. Run developer server npm run dev.

Steps to repare manually:

  1. Delete file node_modules.
  2. Run command npm install.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nikdev15commented, Sep 30, 2021

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.

Thank you @ijjk it worked.

1reaction
ijjkcommented, Sep 30, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found