Npm对等依赖性错误 [英] Npm peer dependency error

查看:247
本文介绍了Npm对等依赖性错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过npm install命令反复收到npm对等项依赖错误.这是我的package.json,我对它的响应和webpack的依赖关系未得到满足

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.

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

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期望您正在使用React 14,但您拥有的是React15.如果将react-datepicker更新为最新版本,则该版本将与v15兼容-也就是说,很少有破坏如果我没记错的话,这两个版本的React之间会发生变化,因此,如果由于某种原因而使用该特定版本的日期选择器,则应该可以安全地忽略该警告.不过,您的里程可能会有所不同.
  • babel-loader依赖于Webpack,但是您尚未安装任何版本.您看来这确实是个错误;运行npm install webpack --save-dev,那应该消失了.
  • 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!

这篇关于Npm对等依赖性错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆