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.

React Invariant thrown during Next.js `next build`

See original GitHub issue

With, npm ls react you can see react@16.14.0 is not deduped, and everything else is on react@17.0.2

...
├─┬ react-dom@17.0.2
│ └── react@17.0.2 deduped
...
├─┬ react-live@2.4.0    (...same issue w/ 2.3.0)
│ ├─┬ prism-react-renderer@1.2.1
│ │ └── react@17.0.2 deduped
│ └─┬ react-simple-code-editor@0.11.0
│   ├─┬ react-dom@16.14.0 <-----------------not deduped
│   │ └── react@16.14.0 deduped
│   └── react@16.14.0 <-----------------not deduped
...
├── react@17.0.2
...

I believe this is preventing my Next.js project from building, due to the more than one copy of React React invariant.

… strangely it only happens when installing everything w/ npm and not yarn


Side: react-simple-code-editor https://github.com/satya164/react-simple-code-editor/blob/master/package.json#L62-L65 doesn’t specify react/-dom 17 as a peer dependency. (It also hasn’t seen a new update in close to 2 years now 😕)

Update: Opened a PR to allow react 17 as a peerDep

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
thiskevinwangcommented, Jan 27, 2022

@jpdriver

Re: original issue, I was able to work around using npm overrides

“react-live”: “^2.3.0”

package.json

...
  "overrides": {
    "react-simple-code-editor": {
      "react": "17.0.2",
      "react-dom": "17.0.2"
    }
  }
}

“react-live”: “^3.0.0-rc1”

This looks to allow react to be deduped 🎉 ,

npm ls react

...
├─┬ react-live@3.0.0-rc1
│ ├─┬ prism-react-renderer@1.2.1
│ │ └── react@17.0.2 deduped
│ └─┬ use-editable@2.3.3
│   └── react@17.0.2 deduped
...

But it looks like it introduces a regression where a previously used style prop is no longer passed along.

1reaction
thiskevinwangcommented, Jan 26, 2022

Hey @jpdriver, awesome! I can test this out in my next chunk of free time and get back to you

And for my context, was that replacement https://github.com/FormidableLabs/use-editable?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nextjs throws Invalid React hooks Error on next dev
When starting server using node app/app.js , the page is loading just fine. But when I run next dev app/src/next or next build...
Read more >
react-hydration-error - Next.js
React Hydration Error. Why This Error Occurred. While rendering your application, there was a difference between the React tree that was pre-rendered ...
Read more >
Migrating from React Router - Next.js
First, uninstall React Router. You'll be migrating to the built-in routing with Next.js. npm uninstall react-router-dom. The Link component for performing ...
Read more >
Routing: Error Handling - Next.js beta docs
Next.js 13 introduced a new file convention, error.js , to help you handle errors in your application. This convention, built on React Error ......
Read more >
Advanced Features: Error Handling - Next.js
React Error Boundaries is a graceful way to handle a JavaScript error on the client so that the other parts of the application...
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