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
npm WARN react-datepicker@0.25.0 requires a peer of react@^0.14.0 but none was installed.
npm WARN babel-loader@6.2.4 requires a peer of webpack@1 || ^2.1.0-beta but none was installed.
npm WARN desktop-react@1.0.0 No repository field.
npm WARN desktop-react@1.0.0 license should be a valid SPDX license expression
{
"name": "xxxxxxxxx",
"version": "x.x.x",
"description": "",
"main": "index.js",
"author": "",
"license": "xxxxxxx",
"dependencies": {
"bootstrap": "^3.3.6",
"fs": "0.0.2",
"history": "^1.17.0",
"immutable": "^3.8.1",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.11.1",
"moment": "^2.13.0",
"react": "^15.0.1",
"react-autosuggest": "^3.7.3",
"react-bootstrap": "^0.29.1",
"react-datepicker": "^0.25.0",
"react-dom": "^15.0.1",
"react-redux": "^4.4.5",
"react-router": "^2.3.0",
"react-select": "^1.0.0-beta12",
"redux": "^3.5.2"
},
"devDependencies": {
"babel-core": "^6.7.7",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"bootstrap": "^3.3.6",
"css-loader": "^0.23.1",
"redux-devtools": "^3.2.0",
"style-loader": "^0.13.1"
}
}
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:react-datepicker
expects you to be using React 14, but you have React 15. If you updatereact-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; runnpm 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 declaresreact@^15.0.0
as a peer dependency.babel-loader
: the installation instructions explain that with npm@3 you need to declare peer dependencies (likewebpack
) explicitly in yourpackage.json
(usingnpm i webpack --save-dev
).The
desktop-react
warnings can be ignored.