Another React question - I’m trying to add a depen...
# dev
t
Another React question - I’m trying to add a dependency to our project and i’m getting the following error:
Copy code
webui % npm i react-diff-viewer

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: lakefs-ui@0.1.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"^17.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^15.3.0 || ^16.0.0" from react-diff-viewer@3.1.1
npm ERR! node_modules/react-diff-viewer
npm ERR!   react-diff-viewer@"*" 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!
Is this safe to use the
--legacy-peer-deps
flag to resolve this? reading about this make me suspect that it can lead to potential conflicts in the future. has anyone ran into a similar error?
@Oz Katz you may have input about this
b
1. you need --save too
👌 1
2. regarding the flag - you need to check the package depends to see if it is safe to use. from what I understand it is probably because of different react versions and how npm specify peer depends
t
@Barak Amar, looking at their peerDependencies they don’t specify react 17 as you mentioned.
Copy code
webui % npm info react-diff-viewer peerDependencies
{ react: '^15.3.0 || ^16.0.0', 'react-dom': '^15.3.0 || ^16.0.0' }
I found this issue https://github.com/praneshr/react-diff-viewer/issues/118 and this (un-merged) pr https://github.com/praneshr/react-diff-viewer/pull/125 which addresses it. How do you suggest to proceed from here? Also, looking at https://github.com/praneshr/react-diff-viewer/blob/v3.1.1/package.json, what sections should I look into to identify dependency conflicts?
b
Looked at the PR it seems to pass the tests and from the change it looks like it doesn't modify any code or dependency - just enable react 17.
The only concern was related to
Copy code
Tests pass locally when using React 17, though you have to install @wojtekmaj/enzyme-adapter-react-17 as an enzyme adapter in order to get them to work. (Enzyme doesn't yet officially support React 17).
So I assume you can install the package using the legacy flag and check if specific package code should be used to have the control work
t
Copy code
webui % npm i react-diff-viewer --save --legacy-peer-deps


added 23 packages, and audited 865 packages in 5s

69 packages are looking for funding
  run `npm fund` for details

29 vulnerabilities (3 moderate, 26 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
check if specific package code should be used to have the control work
Looking into this one, will update here