1

I am using react-collapsed and all my production build is getting failed since morning.

In my package json I am using this "react-collapsed": "^3.3.0",

what i have seen that they have updated something one day ago.

Here is what I am getting...

+ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: react-collapsed@3.6.0
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR!   react@"^18.2.0" from the root project
npm ERR!   peerOptional react@"^16.9.0 || ^17.0.0 || ^18" from @reduxjs/toolkit@1.9.0
npm ERR!   node_modules/@reduxjs/toolkit
npm ERR!     @reduxjs/toolkit@"^1.8.2" from the root project
npm ERR!   12 more (@testing-library/react, dexie-react-hooks, primereact, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8 || ^17" from react-collapsed@3.6.0
npm ERR! node_modules/react-collapsed
npm ERR!   react-collapsed@"^3.6.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@17.0.2
npm ERR! node_modules/react
npm ERR!   peer react@"^16.8 || ^17" from react-collapsed@3.6.0
npm ERR!   node_modules/react-collapsed
npm ERR!     react-collapsed@"^3.6.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /root/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-11-28T07_09_53_802Z-debug-0.log

Now for the solution which I get from stackoverflow is npm config set legacy-peer-deps true

link : Could not resolve dependency error peer react@"^16.8.0 || ^17.0.0" from @material-ui/core@4.12.4

I have two questions related to this

  1. Is it safe to use npm config set legacy-peer-deps true in production env. through ci/cd pipeline.
  2. Do we have any other alternate for that because we probably get similar stuff with any other dependency.

Edit 1 : I have updated with 3.6.0

David
  • 4,266
  • 8
  • 34
  • 69

1 Answers1

0

It looks like you are using react 18 and an old version of react-collapsed@3.3.0. react collapsed 3rd version need old react 16 or 17.

You need to upgrade react-collapsed to the latest version.

  1. It's not safe for production. It's recommended to use the latest version.
  2. above is the alternate option.

Update:

there is react 18 support issue for react-collapsed, so you can try the below patch for the alternative:

https://www.npmjs.com/package/@gaearon/react-collapsed?activeTab=versions

Abasaheb Gaware
  • 509
  • 4
  • 13