react-nativenpmexponative-base

How to overcome ERESOLVE errors within EAS build for native-base and Expo?


I have got the following package.json file. Main purpose is to use Expo 44 with native-base (version ^3.0.0). I could not figure out why such an obvious combination does not work. (Could not find online for native-base, which Expo versions are recommended either.)

package.json:

{
    "main": "node_modules/expo/AppEntry.js",
    "scripts": {
        "start": "expo start",
        "android": "expo start --android",
        "ios": "expo start --ios",
        "eject": "expo eject",
        "test": "node ./node_modules/jest/bin/jest.js --watchAll"
    },
    "dependencies": {
        "@expo/samples": "2.1.1",
        "@expo/vector-icons": "^12.0.0",
        "@react-native-async-storage/async-storage": "~1.15.0",
        "@react-native-community/datetimepicker": "4.0.0",
        "@react-native-community/netinfo": "7.1.3",
        "@react-native-picker/picker": "2.2.1",
        "expo": "^44.0.0",
        "expo-ads-admob": "~12.0.0",
        "expo-app-loading": "~1.3.0",
        "expo-apple-authentication": "~4.1.0",
        "expo-application": "~4.0.1",
        "expo-asset": "~8.4.5",
        "expo-auth-session": "~3.5.0",
        "expo-av": "~10.2.0",
        "expo-facebook": "~12.1.0",
        "expo-font": "~10.0.4",
        "expo-haptics": "~11.1.0",
        "expo-image-manipulator": "~10.2.0",
        "expo-random": "~12.1.1",
        "expo-screen-orientation": "~4.1.1",
        "expo-sharing": "~10.1.0",
        "expo-tracking-transparency": "~2.1.0",
        "moment": "^2.24.0",
        "native-base": "^3.0.0",
        "react": "17.0.1",
        "react-native": "0.64.3",
        "react-native-gesture-handler": "~2.1.0",
        "react-native-modal-datetime-picker": "^8.6.0",
        "react-native-picker-select": "^8.0.0",
        "react-native-progress": "^4.1.2",
        "react-native-progress-circle": "^2.1.0",
        "react-native-safe-area-context": "3.3.2",
        "react-native-svg": "12.1.1",
        "react-native-view-shot": "3.1.2",
        "react-native-webview": "11.15.0",
        "react-redux": "^6.0.0",
        "redux": "^4.0.1"
    },
    "devDependencies": {
        "babel-preset-expo": "9.0.1"
    },
    "resolutions": {},
    "private": true
}

Even though all the local debugging and simulator runs work without problem, when the EAS try to build, following errors (coming from npm) are seen.

[stderr] npm ERR! code ERESOLVE
[stderr] npm
[stderr] ERR! ERESOLVE unable to resolve dependency tree
[stderr] npm ERR! 
[stderr] npm ERR! While resolving: undefined@undefined
[stderr] npm ERR! Found: react@17.0.1
[stderr] npm ERR! node_modules/react
[stderr] npm ERR!
[stderr] react@"17.0.1" from the root project
[stderr] npm ERR!   peer react@"*" from native-base@3.3.6
[stderr] npm ERR!   node_modules/native-base
[stderr] npm ERR!     native-base@"^3.0.0" from the root project
[stderr] npm ERR! 
[stderr] npm ERR! Could not resolve dependency:
[stderr] npm ERR! peer react@"17.0.2" from react-dom@17.0.2
[stderr] npm ERR! node_modules/react-dom
[stderr] npm ERR!   peer react-dom@"*" from native-base@3.3.6
[stderr] npm ERR!   node_modules/native-base
[stderr] npm ERR!     native-base@"^3.0.0" from the root project
[stderr] npm ERR! 
[stderr] npm ERR! Fix the upstream dependency conflict, or retry
[stderr] npm ERR! this command with --force, or --legacy-peer-deps
[stderr] npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
[stderr] npm ERR! 
[stderr] npm ERR! See /Users/expo/.npm/eresolve-report.txt for a full report.
[stderr] 
[stderr] npm ERR! A complete log of this run can be found in:
[stderr] npm ERR!     /Users/expo/.npm/_logs/2022-02-14T09_22_49_729Z-debug.log
npm exited with non-zero code: 1

How to overcome this problem, any ideas?

Chronology:

Other Info:

which build of the expo is failing android or ios.

ios

commands you are using to build.

eas build --platform ios --non-interactive

which package manager are you in this project ? yarn or npm.

I use yarn but eas build seems using npm

any other things which will be useful to replicate this error.

Unfortunately I don't have any other clue.


Solution

  • It seems native-base searches "react-dom": "*" and could not find it so somehow uses "react-dom": "17.0.2" and it in turn looks for "react": "17.0.2" which conflicts with expo's "react": "17.0.1".

    So adding "react-dom": "17.0.1" as dependency solved the problem. By this way "react-dom": "*" finds "react-dom": "17.0.1" which is dependent to Expo's version "react": "17.0.1". (Please let me know if this conclusion is wrong.)

    Following are the ones related with native-base and these versions should be used otherwise the npm install fails for Expo 44:

            "react-dom": "17.0.1",
            "react-native-safe-area-context": "3.1.9",
            "react-native-svg": "12.1.0",
    

    Reference: https://github.com/GeekyAnts/NativeBase/issues/4647