当我在当前的反应项目上运行npm i
时,我收到以下有关反应peerDependency的警告:
npm WARN [email protected] requires a peer of react@^16.0.0-0 < 16.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^15.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^0.14.0 || ^15.0.0 but none is installed. You must install peer dependencies yourself.
在我的package.json中,我使用的是最新版本的react:
"react": "^16.7.0"
我是node和npm的新手。我想知道安装npm peerDependencies的好习惯是什么:
1.)如果已在package.json中指定了更新版本,则可以忽略较低版本的警告。
2.)根据https://lexi-lambda.github.io/blog/2016/08/24/understanding-the-npm-dependency-model/和https://github.com/npm/npm/issues/6565
npm提供依赖隔离,peerDepencies需要手动安装,所以我应该安装所有3个版本的反应,但我担心会破坏import语句。
3.)如果以上两者都不是,我应该在package.json中使用哪个版本。附:我的package.json中有很多依赖项,也可能需要最新版本。
进一步考虑Danyal的答案,你可以升级formy-react并删除react-tap-event-plugin:
对等依赖性意味着包适用于与特定版本的依赖项一起使用,如果超出指定版本,则无法按预期工作。
在你的情况下,[email protected]
需要一个小于16.4.0的React版本,[email protected]
需要任何版本的React 15和[email protected]
相同。
您需要从React 16.7.0降级,但如果您使用16.7.0功能,则可能会破坏您的应用程序,或者您可以删除软件包并使用另一个软件包或从开始自己编写软件包的逻辑。
提示:在实际考虑使用项目包之前,请务必确保在npm网站上阅读包依赖项。