一尘不染

Npm对等依赖性错误

node.js

我使用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"

  }

}

阅读 448

收藏
2020-07-07

共1个答案

一尘不染

好吧,首先,这些不是错误,它们是警告。它们实际上并不会阻止您的代码运行,只是在您的依赖项有问题的情况下提醒您。

实际上,peerDependencies软件包是一种指定方式,“使用我,您还应该安装 y 软件包的 x 版本”。就您而言,有两个问题: __

  • 该版本的react-datepicker期望您使用的是React 14,但是您拥有的是React15。如果您更新react-datepicker到最新版本,则该版本将与v15兼容-也就是说,如果我在这两个版本之间进行很少的重大更改,没记错的话,所以,如果你坚持使用的日期选择器由于某种原因的特定版本,它 应该 是安全的忽略警告。但是,您的里程可能会有所不同。
  • babel-loader依赖Webpack,但是您尚未安装任何版本。您看来这确实是一个错误;跑npm install webpack --save-dev,那应该消失。

希望在这种情况下,您将来能够了解如何解释这些警告!

2020-07-07