Npm peer dependency error

前端 未结 2 422
北海茫月
北海茫月 2020-12-20 16:10

I am getting the npm peer dependency error repeatedly with npm install command . This is my package.json on which i have unmet peer dependency on react and webpack



        
相关标签:
2条回答
  • 2020-12-20 16:51

    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!

    0 讨论(0)
  • 2020-12-20 16:55

    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.

    0 讨论(0)
提交回复
热议问题