安装颜色检测库时出现反应错误

问题描述 投票:0回答:1

我有这个 Spotify 克隆项目。我正在尝试检测图像的主色并将该颜色用作背景色。

目前,我尝试使用 color-theif、node-vibrant、extract-colors 库。但在将这些库之一添加到我的项目中时,我遇到了以下错误。

我该如何解决这个问题?

错误-

PS D:\React\spotify-clone> **npm install color-thief**
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/axios
npm ERR!   axios@"^1.6.7" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer axios@"^0.27.2" from [email protected]
npm ERR! node_modules/react-axios
npm ERR!   react-axios@"^2.0.6" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/axios
npm ERR!   peer axios@"^0.27.2" from [email protected]
npm ERR!   node_modules/react-axios
npm ERR!     react-axios@"^2.0.6" 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.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\Prashant\AppData\Local\npm-cache\_logs\2024-02-17T13_30_34_980Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: C:\Users\Prashant\AppData\Local\npm-cache\_logs\2024-02-17T13_30_34_980Z-debug-0.log



PS D:\React\spotify-clone> **npm install --save extract-colors**
npm ERR!   react-axios@"^2.0.6" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/axios
npm ERR!   peer axios@"^0.27.2" from [email protected]
npm ERR!   node_modules/react-axios
npm ERR!     react-axios@"^2.0.6" 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.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\Prashant\AppData\Local\npm-cache\_logs\2024-02-17T13_46_00_204Z-eresolve-report.txt

下面是我的package.json文件

{
  "name": "spotify-clone",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^1.6.7",
    "express": "^4.18.2",
    "react": "^18.2.0",
    "react-axios": "^2.0.6",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.20.0",
    "react-scripts": "5.0.1",
    "react-spinners": "^0.13.8",
    "swiper": "^11.0.4",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "both": "concurrently \"npm run start\" \"nodemon backend/index.js\""
  },
  "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"
    ]
  },
  "devDependencies": {
    "@babel/plugin-transform-private-property-in-object": "^7.23.3",
    "tailwindcss": "^3.3.5"
  }
}

javascript reactjs node.js image-processing dependencies
1个回答
0
投票

问题不在于颜色检测库包;

问题在于

react-axios
,这是一个过时的版本。就你而言,

只需运行

npm uninstall axios
即可解决它。

© www.soinside.com 2019 - 2024. All rights reserved.