简体   繁体   English

如何解决依赖 npm 冲突?

[英]How to resolve dependencies npm conflict?

package.json package.json

{
  "name": "reactjs",
  "version": "4.7.1",
  "private": true,
  "dependencies": {
    "@ant-design/icons": "^4.2.2",
    "@aspnet/signalr": "^1.1.4",
    "@craco/craco": "^5.6.2",
    "@fullcalendar/bootstrap": "^5.9.0",
    "@fullcalendar/core": "4.4.0",
    "@fullcalendar/daygrid": "^5.9.0",
    "@fullcalendar/interaction": "^5.9.0",
    "@fullcalendar/react": "^5.9.0",
    "@fullcalendar/timegrid": "4.4.2",
    "@types/d3-scale": "^4.0.2",
    "@types/react-bootstrap-table-next": "^4.0.18",
    "abp-web-resources": "^5.1.1",
    "antd": "^4.6.4",
    "apexcharts": "^3.35.2",
    "axios": "^0.19.0",
    "bootstrap": "^5.1.0",
    "classnames": "^2.2.6",
    "craco-antd": "^1.14.1",
    "d3-scale": "^4.0.2",
    "echarts": "^5.3.2",
    "echarts-for-react": "^3.0.2",
    "env-cmd": "^10.1.0",
    "famfamfam-flags": "^1.0.0",
    "formik": "^2.2.9",
    "highcharts": "^10.2.0",
    "highcharts-react-official": "^3.1.0",
    "lodash": "^4.17.15",
    "mobx": "^6.5.0",
    "mobx-react": "^7.4.0",
    "mobx-react-lite": "^3.4.0",
    "moment": "^2.24.0",
    "moment-timezone": "^0.5.27",
    "query-string": "^6.9.0",
    "rc-slider": "^8.7.1",
    "rc-tooltip": "^4.0.0-alpha.3",
    "react": "^18.1.0",
    "react-apexcharts": "^1.4.0",
    "react-bootstrap": "^2.0.0-beta.6",
    "react-bootstrap-table-next": "^3.3.5",
    "react-bootstrap-table2-editor": "^1.4.0",
    "react-bootstrap-table2-paginator": "^2.1.1",
    "react-bootstrap-table2-toolkit": "^2.1.1",
    "react-datepicker": "^2.11.0",
    "react-datetime": "^2.16.3",
    "react-document-title": "^2.0.3",
    "react-dom": "^18.1.0",
    "react-image-crop": "^9.0.3",
    "react-loadable": "^5.5.0",
    "react-notifications": "^1.4.3",
    "react-perfect-scrollbar": "^1.5.3",
    "react-quill": "^1.3.3",
    "react-router-dom": "^5.1.2",
    "react-scripts": "^3.2.0",
    "react-select": "^5.3.2",
    "react-vis": "^1.11.7",
    "recharts": "^1.8.5",
    "sass": "^1.51.0",
    "sweetalert2": "^9.5.4",
    "sweetalert2-react": "^0.8.3",
    "yup": "^0.32.11"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "scripts": {
    "start": "env-cmd -f .env.dev craco start",
    "start-local": "env-cmd -f .env.local craco start",
    "start-production": "env-cmd -f .env.production craco start",
    "build": "env-cmd -f .env.dev craco build",
    "build-local": "env-cmd -f .env.local craco build",
    "build-production": "env-cmd -f .env.production craco build",
    "lint": "eslint . --ext .ts,.tsx",
    "test": "craco test",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "@types/classnames": "^2.2.9",
    "@types/jest": "^24.0.23",
    "@types/moment": "^2.13.0",
    "@types/moment-timezone": "^0.5.12",
    "@types/node": "^12.12.14",
    "@types/react": "^16.9.13",
    "@types/react-datepicker": "^4.4.1",
    "@types/react-document-title": "^2.0.3",
    "@types/react-dom": "^16.9.4",
    "@types/react-loadable": "^5.5.2",
    "@types/react-router-dom": "^5.1.3",
    "@types/react-vis": "^1.11.11",
    "@types/recharts": "^1.8.3",
    "@typescript-eslint/eslint-plugin": "^4.0.1",
    "@typescript-eslint/parser": "^4.0.1",
    "copy-webpack-plugin": "^5.0.5",
    "eslint": "^6.8.0",
    "eslint-config-airbnb-typescript": "^9.0.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jest": "^23.17.1",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-prettier": "^3.1.4",
    "eslint-plugin-react": "^7.20.6",
    "eslint-plugin-react-hooks": "^4.1.0",
    "prettier": "^2.0.5",
    "ts-import-plugin": "^1.6.1",
    "typescript": "^3.7.2"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "resolutions": {
    "@types/react": "16.3.0"
  }
}

What I've done:我做了什么:

  • yarn - install correctly but finally I had: screenshot yarn - 安装正确,但我终于有了:截图
  • npm ci npm ci
  • npm i npm i
  • npm i --force and npm i --legacy-peer-deps(both install modules, but finally I had an error) npm i --force 和 npm i --legacy-peer-deps (都安装模块,但最后我有一个错误)
  • tried to add resolutions to package.json试图将分辨率添加到 package.json
  • deleted package-lock, yarn.lock and node_modules and after npm i or yarn删除 package-lock、yarn.lock 和 node_modules 以及 npm i 或 yarn 之后
  • tried different versions of react in resolution package在分辨率 package 中尝试了不同版本的反应

Node version: tried with 14.15 and then updated to 16.17 NPM: 8.11.0节点版本:尝试使用 14.15,然后更新到 16.17 NPM:8.11.0

with resolutions like I have in package.json: screenshot具有像我在 package.json 中的分辨率:屏幕截图

without resolutions: screenshot没有分辨率:截图

Got a archive with all fronted files(with node modules) and tried to start(failed), but on other windows machine project started correctly(Node 14.15, npm version 6)获得了包含所有前端文件(带有节点模块)的存档并尝试启动(失败),但在其他 windows 机器项目上正确启动(节点 14.15,npm 版本 6)

UPD new error: screenshot UPD 新错误:截图

UPD 2: maybe it makes more sense to resolve the issues from the first screen shot? UPD 2:也许从第一个屏幕截图中解决问题更有意义?

If you want to resolve your dependencies you will have to change the used versions.如果要解决依赖关系,则必须更改使用的版本。 your package.json requires "react": "^18.1.0", while react-bootstrap-table-next requires "react": "^16.3.0", .您的package.json需要"react": "^18.1.0",react-bootstrap-table-next需要"react": "^16.3.0",

If you want to resolve your conflict you will have to update react-bootstrap-table-next to a version which supports "react": "^18.1.0", or downgrade your react dependency in the package.json to "react": "^16.3.0",如果要解决冲突,则必须将react-bootstrap-table-next更新为支持"react": "^18.1.0",或将package.json中的 react 依赖项降级为"react": "^16.3.0",

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM