简体   繁体   中英

package.json override dependencies peer dependencies

When running npm i in one of my projects I get the follow error:

npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.13.1" from react-qr-barcode-scanner@1.0.6
npm ERR! node_modules/react-qr-barcode-scanner
npm ERR!   react-qr-barcode-scanner@"*" 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.

I have read about the overrides property in package.json but this only seems to work for overriding "regular" dependencies.

I do also know that I can simply run npm i --legacy-peer-deps as the error suggests but I can't help but wonder:

Is there a way to override a dependencies peer dependencies without requiring --legacy-peer-deps ?

this happens all the time with react, and i eventually plan to abandon react. however this worked for me.

npm update; npm i --force

secondly. your next option is clear package.json. and npm init. and try installing latest versions of all dependencies. and never upgrade until absolutely necessary.

This is a known issue , seems like author dropped support for this package.

You can replace with forked one to solve this problem, created by @steima

https://www.npmjs.com/package/@steima/react-qr-barcode-scanner

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM