next.js: "Invalid hook call" in 11.1.2

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

What operating system are you using?

Windows 10

How are you deploying your application?

next dev

Describe the Bug

The CSS issue in Windows is cleared up, but this new one appears on any fresh NextJS project:

`Server Error 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.`

Expected Behavior

NextJS would work as it did before 11.1.1.

To Reproduce

npx create-next-app (anything)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 25 (22 by maintainers)

Most upvoted comments

I’m going to close this as the initial issue appears to be resolved and was due to next being installed globally.

@igorbarbashin if you are having trouble with a specific package please open a help discussion https://github.com/vercel/next.js/discussions/categories/help and it can be investigated there.

I uninstalled next globally, and that seems to have done the trick so far! Running yarn dev and that starter homepage popped up.

@Ultharite is next install globally for you? next shouldn’t be able to be run without prefixing it with yarn since it won’t resolve correctly to node_modules/.bin automatically without.

Note: next is not meant be installed globally and can cause this error to occur