Npm对等依赖性错误

时间:2016-05-12 11:02:39

标签: node.js npm package.json

我使用npm install命令重复获取npm对等依赖性错误。这是我的package.json,我对react和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"
  }
}




2 个答案:

答案 0 :(得分:10)

嗯,首先,这些都不是错误,而是警告。他们实际上不会阻止您的代码运行,如果您的依赖项出现问题,他们会在那里为您提供帮助。

实际上,peerDependencies是包指定的方式,"要使用我,您还应该安装 x y 包& #34 ;.在您的情况下,您有两个问题:

  • react-datepicker的那个版本希望你使用React 14,但你有React 15.如果你将react-datepicker更新到最新版本,那个版本将与v15兼容 - 那就是说,那里如果我没记错的话,那两个版本的React之间的变化非常少,所以如果你因为某种原因而不能使用特定版本的日期选择器, 可以安全地忽略它警告。不过,您的里程可能会有所不同。
  • babel-loader依赖于Webpack,但您没有安装任何版本的版本。这似乎是你的错误;运行npm install webpack --save-dev,这应该消失。

希望通过这种背景,您将能够理解将来如何解释这些警告!

答案 1 :(得分:2)

有警告,而不是错误,但它仍然值得修复。

desktop-react警告可以忽略。