ERESOLVE 无法解析依赖树

Posted

技术标签:

【中文标题】ERESOLVE 无法解析依赖树【英文标题】:ERESOLVE unable to resolve dependency tree 【发布时间】:2021-08-04 14:15:43 【问题描述】:

我有一个现有的项目,我正在努力让它运行,但我面临很多问题。 安装时出现此错误“ERESOLVE 无法解析依赖关系树”

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: react-native-starter@2.0.0
npm ERR! Found: react-native@0.59.1
npm ERR! node_modules/react-native
npm ERR!   react-native@"0.59.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react-native@"^0.41.2" from react-native-android-installed-apps@1.0.1
npm ERR! node_modules/react-native-android-installed-apps
npm ERR!   react-native-android-installed-apps@"^1.0.1" 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! See /home/user/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2021-05-14T11_31_41_074Z-debug.log

package.json


  "name": "react-native-starter",
  "version": "2.0.0",
  "private": false,
  "scripts": 
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "test:update": "jest -u",
    "test:coverage": "jest --coverage",
    "run:ios": "react-native run-ios",
    "run:android": "react-native run-android",
    "lint": "./node_modules/eslint/bin/eslint.js src",
    "lint:fix": "./node_modules/eslint/bin/eslint.js src --fix",
    "flow": "./node_modules/flow-bin/cli.js",
    "e2e:build": "detox build --configuration ios.sim.debug",
    "e2e:test": "detox test --configuration ios.sim.debug"
  ,
  "dependencies": 
    "@exponent/react-native-action-sheet": "^0.3.0",
    "@jumpn/react-native-jetifier": "^0.1.4",
    "@react-native-community/art": "^1.1.2",
    "dev": "^0.1.3",
    "i18n-js": "^3.2.1",
    "jetifier": "^1.6.4",
    "lodash": "^4.17.11",
    "lottie-react-native": "^3.3.2",
    "react": "16.8.3",
    "react-keyboard-event-handler": "^1.5.2",
    "react-native": "0.59.1",
    "react-native-android-installed-apps": "^1.0.1",
    "react-native-camera": "^3.4.0",
    "react-native-contacts": "3.1.5",
    "react-native-countdown-circle": "^3.0.1",
    "react-native-datepicker": "^1.7.2",
    "react-native-device-info": "^3.1.4",
    "react-native-elements": "^1.1.0",
    "react-native-fbsdk": "^0.10.3",
    "react-native-firebase": "^5.5.6",
    "react-native-flexi-radio-button": "^0.2.2",
    "react-native-geolocation-service": "^3.1.0",
    "react-native-gesture-handler": "1.0.16",
    "react-native-get-sms-android": "^2.0.0",
    "react-native-image-picker": "1.x.x",
    "react-native-image-view": "^2.1.9",
    "react-native-indicator": "^1.0.0",
    "react-native-lightbox": "^0.8.0",
    "react-native-linear-gradient": "^2.5.3",
    "react-native-localize": "^1.0.4",
    "react-native-maps": "^0.27.1",
    "react-native-material-dropdown": "^0.11.1",
    "react-native-material-textfield": "^0.16.1",
    "react-native-modal": "^9.0.0",
    "react-native-modal-datetime-picker": "^6.0.0",
    "react-native-modal-dropdown": "^0.6.2",
    "react-native-nav": "^2.0.2",
    "react-native-popup-dialog": "^0.18.3",
    "react-native-push-notification": "^3.1.9",
    "react-native-razorpay": "^2.2.2",
    "react-native-responsive-screen": "^1.4.1",
    "react-native-select-contact-fix": "^1.3.2",
    "react-native-share": "^4.1.0",
    "react-native-sim-data": "^3.0.0",
    "react-native-simple-toast": "^0.1.1",
    "react-native-sms": "^1.9.0",
    "react-native-step-indicator": "^1.0.3",
    "react-native-svg": "^9.13.6",
    "react-native-svg-img": "^2.0.6",
    "react-native-swiper-flatlist": "^2.0.4",
    "react-native-switch-selector": "^2.0.6",
    "react-native-ui-lib": "^3.18.0",
    "react-native-ui-xg": "^0.0.6",
    "react-native-vector-icons": "^6.6.0",
    "react-native-webview": "^7.4.3",
    "react-navigation": "^3.3.2",
    "react-navigation-header-buttons": "^2.1.2",
    "react-navigation-material-bottom-tabs": "^1.0.0",
    "react-navigation-transitions": "^1.0.12",
    "react-redux": "^6.0.1",
    "recompose": "^0.30.0",
    "redux": "^4.0.1",
    "redux-logger": "^3.0.6",
    "redux-persist": "^5.10.0",
    "redux-promise": "^0.6.0",
    "redux-thunk": "^2.3.0",
    "rn-tri-toggle-switch": "^1.0.4"
  ,
  "devDependencies": 
    "@babel/core": "^7.3.4",
    "@babel/preset-flow": "^7.0.0",
    "babel-eslint": "^10.0.1",
    "babel-jest": "^24.5.0",
    "danger": "^7.0.2",
    "detox": "^9.1.2",
    "enzyme": "^3.7.0",
    "enzyme-adapter-react-16": "^1.7.0",
    "eslint": "^5.9.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-prettier": "^3.6.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.2",
    "eslint-plugin-react": "^7.11.1",
    "flow-bin": "0.92.0",
    "jest": "^24.5.0",
    "jsdom": "13.0.0",
    "jsdom-global": "3.0.2",
    "metro-react-native-babel-preset": "^0.53.1",
    "plop": "^2.2.0",
    "prettier": "^1.16.1",
    "react-addons-test-utils": "^15.6.2",
    "react-dom": "^16.6.3",
    "react-test-renderer": "16.8.3",
    "sinon": "^7.1.1"
  ,
  "jest": 
    "preset": "react-native",
    "transform": 
      "^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
    ,
    "collectCoverage": true,
    "collectCoverageFrom": [
      "src/**/*.js,jsx",
      "!**/node_modules/**",
      "!android/**",
      "!ios/**",
      "!assets/**"
    ],
    "coverageDirectory": "jest_coverage",
    "setupFiles": [
      "./jest-setup.js"
    ],
    "testPathIgnorePatterns": [
      "/node_modules/",
      "/e2e/"
    ]
  ,
  "rnpm": 
    "assets": [
      "./assets/fonts/"
    ]
  ,
  "detox": 
    "configurations": 
      "ios.sim.debug": 
        "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/ReactNativeStarter.app",
        "build": "xcodebuild -UseModernBuildSystem=NO -project ios/ReactNativeStarter.xcodeproj -scheme ReactNativeStarter -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "name": "iPhone XS"
      ,
      "ios.sim.release": 
        "binaryPath": "ios/build/Build/Products/Release-iphonesimulator/ReactNativeStarter.app",
        "build": "xcodebuild -UseModernBuildSystem=NO -project ios/ReactNativeStarter.xcodeproj -scheme ReactNativeStarter -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "name": "iPhone 7"
      
    ,
    "test-runner": "jest"
  

PS:我对 React Native 一无所知,所以请相应地给出答案。如果您需要什么,请告诉我

我已经删除了 node_modules 和 package_json_lock

【问题讨论】:

升级到 'react-native' 版本 0.64.1 为我解决了这个问题。 @Rohit 运行 npx react-native upgrade 后出现错误致命:不是 git 存储库(或任何父目录):.git 我解决了这个问题,但不记得如何解决了,对不起 【参考方案1】:

你可以尝试 npm install node 或者,如果这也不起作用,你可以使用 yarn install。如果你使用yarn install,在以后的命令中使用yarn的特定代码(与npm相比没有太大区别)

【讨论】:

【参考方案2】:

可能降级到 v12.16.1 也可以 &运行

npm install --save --legacy-peer-deps

【讨论】:

这个问题已经解决了,我不记得是怎么解决的了,花了 1 周的时间解决了这个问题,但它已经解决了。现在不知道怎么处理这个问题

以上是关于ERESOLVE 无法解析依赖树的主要内容,如果未能解决你的问题,请参考以下文章

由于 ERESOLVE 无法解析依赖关系树,因此无法安装软件包 Pinia

ngx-datatable ERESOLVE 无法解析依赖树

创建离子应用程序时无法解析依赖树

无法使用 eslint-config-airbnb 解析依赖关系树

Npm 漏洞无法修复

npm install 无法解析依赖树