2

I'm trying to understand why I'm receiving a dependency tree error when I try to install the react-native-deck-swiper package. I've already bypassed the error and installed the package using --force or --legacy-peer-deps, but I would like to understand what is causing the error in the first place.

I'm working on a react project using React (18.1.0), react-native (0.70.5), and I'm trying to install a package called react-native-deck-swiper (latest version is 2.0.11). When I do

npm i react-native-deck-swiper

I get the following error message:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: flashcards@1.0.0
npm ERR! Found: react-native@0.70.5
npm ERR! node_modules/react-native
npm ERR!   react-native@"0.70.5" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react-native@"^0.49.1" from react-native-deck-swiper@2.0.11
npm ERR! node_modules/react-native-deck-swiper
npm ERR!   react-native-deck-swiper@"*" 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.

It appears to be telling me that the package (react-native-deck-swiper) requires react-native ^0.49.1, which I believe means any react-native package that starts with "0." should be acceptable. Since I am using "0.70.5", that should be okay, so why am I getting an error?

The dependencies for my project looks like this:


  "dependencies": {
    "@react-navigation/native": "^6.0.13",
    "@react-navigation/native-stack": "^6.9.1",
    "expo": "~47.0.3",
    "expo-status-bar": "~1.4.2",
    "nativewind": "^2.0.11",
    "react": "18.1.0",
    "react-native": "0.70.5",
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "tailwindcss": "^3.2.4"
  },


The dependencies for react-native-deck-swiper, which I'm trying to install, looks like this:

"dependencies": {
        "prop-types": "15.5.10"
    },
    "peerDependencies": {
        "react": "^16.0.0-beta.5 || ^17.0.0 || ^18.0.0",
        "react-native": "^0.49.1"
    },
    "devDependencies": {
        "babel-eslint": "^7.2.3",
        "babel-jest": "18.0.0",
        "babel-preset-react-native": "1.9.1",
        "eslint": "^3.19.0",
        "eslint-config-standard": "^10.2.1",
        "eslint-config-standard-react": "^5.0.0",
        "eslint-plugin-import": "^2.7.0",
        "eslint-plugin-json": "^1.2.0",
        "eslint-plugin-node": "^5.1.1",
        "eslint-plugin-promise": "^3.5.0",
        "eslint-plugin-react": "^7.2.1",
        "eslint-plugin-standard": "^3.0.1",
        "jest": "18.1.0",
        "jest-cli": "^18.1.0",
        "lodash": "^4.17.5",
        "prettier-eslint": "^6.4.2",
        "prettier-eslint-cli": "^4.1.1",
        "react-test-renderer": "15.4.2"
    },

Thank you for your help!

Alex
  • 86
  • 4

0 Answers0