我正在学习电子商务教程,无法使用react 18在npm中安装所有包react-paypal按钮。
npm i react-paypal-smart-button
结果:
npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! 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 C:\Users\a\AppData\Local\npm-cache\eresolve-report.txt for a full report. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\a\AppData\Local\npm-cache\_logs\2023-02-09T15_12_52_013Z-debug-0.log
react-paypal-smart-button 有这样的peerDeps:
"peerDependencies": {
"prop-types": "^15.6.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
并且您安装了 React 版本 18。 因此,只需使用标志 npm i--legacy-peer-deps 来忽略该警告。 (然后react-paypal-smart-button将使用你的react 18而不是推荐的17。希望这不会破坏包:))
关于peerDeps - https://nodejs.org/es/blog/npm/peer-dependency/