Npm peer dependency error

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 13:27:54

Well, firstly, those aren't errors, they're warnings. They won't actually stop your code from running, they're just there to give you a heads up if there's something wrong with your dependencies.

Effectively, peerDependencies are a way for packages to specify, "to use me, you should also have x version of y package installed". In your case, you have two issues:

  • That version of react-datepicker expects you to be using React 14, but you have React 15. If you update react-datepicker to the newest version, that one will be compatible with v15 - that said, there were very few breaking changes between those two version of React if I remember correctly, so if you're stuck using that particular version of the date picker for some reason, it should be safe to ignore that warning. Your mileage may vary, though.
  • babel-loader relies on Webpack, but you don't have any version of it installed. This does seem like a mistake on your part; run npm install webpack --save-dev and that should go away.

Hopefully with that context you'll be able to understand how to interpret those warnings in the future!

There are warnings, not errors, but it's still worthwhile to fix.

  • react-datepicker: you should upgrade to the latest version (0.27.0), which declares react@^15.0.0 as a peer dependency.
  • babel-loader: the installation instructions explain that with npm@3 you need to declare peer dependencies (like webpack) explicitly in your package.json (using npm i webpack --save-dev).

The desktop-react warnings can be ignored.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!