簡體   English   中英

反應依賴樹問題

[英]React Dependency Tree Issue

誰能告訴我這里有什么問題? 我正在嘗試安裝 mui 搜索欄組件。

npm i --save material-ui-search-bar

但是我確實收到以下信息:

PS Z:\WebDev\ApplyWithin\frontend> npm i --save material-ui-search-bar
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: new@0.1.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR!   peer react@"^16.8.0 || ^17.0.0" from @material-ui/core@4.12.3
npm ERR!   node_modules/@material-ui/core
npm ERR!     peer @material-ui/core@"^4.0.0" from material-ui-search-bar@1.0.0
npm ERR!     node_modules/material-ui-search-bar
npm ERR!       material-ui-search-bar@"*" from the root project
npm ERR!     peer @material-ui/core@"^4.0.0" from @material-ui/icons@4.11.2
npm ERR!     node_modules/@material-ui/icons
npm ERR!       @material-ui/icons@"^4.11.2" from the root project
npm ERR!       1 more (material-ui-search-bar)
npm ERR!   2 more (react-dom, @material-ui/icons)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from material-ui-search-bar@1.0.0
npm ERR! node_modules/material-ui-search-bar
npm ERR!   material-ui-search-bar@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

我的 package.json 是:

{
  "name": "new",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@emotion/react": "^11.7.0",
    "@emotion/styled": "^11.6.0",
    "@fontsource/roboto": "^4.5.1",
    "@material-ui/icons": "^4.11.2",
    "@mui/icons-material": "^5.2.4",
    "@mui/material": "^5.2.3",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "framer-motion": "^4.1.17",
    "gsap": "^3.9.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-intersection-observer": "^8.33.1",
    "react-scripts": "4.0.3",
    "react-typewriter-effect": "^1.1.0",
    "styled-components": "^5.3.3",
    "typewriter-effect": "^2.18.2",
    "web-vitals": "^1.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

有人在這里有線索嗎?

問題似乎與 material-ui-search-bar 的對等依賴性有關。 擁有對等依賴意味着您的 package 需要一個與安裝 package 的人完全相同的依賴。

如您發布的錯誤中所述。 它需要反應版本 ^16.8.0 或更低版本才能運行。 在此處輸入圖像描述

但是在您的項目中,您指定了更大版本的 react - ^17.0.2。 在此處輸入圖像描述

你可以做的是降低你的反應版本。 那么您應該可以毫無問題地安裝上述 package。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM