Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

node.js - Npm peer dependency error

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 [email protected] requires a peer of react@^0.14.0 but none was installed.
    npm WARN [email protected] requires a peer of webpack@1 || ^2.1.0-beta but none was installed.
    npm WARN [email protected] No repository field.
    npm WARN [email protected] 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"
  }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...