Classic build works but not EAS Build

my project works with classic build but not EAS. I also tried upgradin gto latest expo sdk and got similar errors.

Managed workflow
eas-cli/0.47.0 darwin-x64 node-v16.13.2

Running npm in the root dir of your repository 
[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@16.13.1
[stderr] npm ERR! node_modules/react
[stderr] npm ERR!   react@"16.13.1" from the root project
[stderr] npm ERR!   peer react@">= 16.0 || < 17.0" from react-native-maps@0.28.0
[stderr] npm ERR!   node_modules/react-native-maps
[stderr] npm ERR!     react-native-maps@"0.28.0" from the root project
[stderr] npm ERR!   2 more (react-native, react-native-web)
[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@">=16.5.1" from react-native-web@0.11.7
[stderr] npm ERR!   node_modules/react-native-web
[stderr] npm ERR!     peer react-native-web@"^0.11" from react-native-maps@0.28.0
[stderr] npm ERR!     node_modules/react-native-maps
[stderr] npm ERR!       react-native-maps@"0.28.0" from the root project
[stderr] npm
[stderr] 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 /home/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!     /home/expo/.npm/_logs/2022-02-21T06_33_07_216Z-debug.log
npm exited with non-zero code: 1

package.json

{
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "publish": "expo publish",
    "build:ios": "expo build:ios",
    "build:android": "expo build:android -t app-bundle",
    "eject": "expo eject",
    "lint": "eslint "
  },
  "dependencies": {
    "@expo/vector-icons": "^12.0.0",
    "@react-native-async-storage/async-storage": "~1.15.0",
    "axios": "^0.19.2",
    "expo": "^42.0.0",
    "expo-analytics-amplitude": "~10.2.0",
    "expo-app-loading": "1.1.2",
    "expo-application": "3.2.0",
    "expo-asset": "~8.3.3",
    "expo-blur": "~9.0.3",
    "expo-constants": "~11.0.1",
    "expo-device": "^3.3.0",
    "expo-file-system": "~11.1.3",
    "expo-font": "~9.2.1",
    "expo-image-picker": "~10.2.2",
    "expo-intent-launcher": "~9.1.0",
    "expo-linear-gradient": "~9.2.0",
    "expo-linking": "~2.3.1",
    "expo-localization": "~10.2.0",
    "expo-location": "~12.1.2",
    "expo-permissions": "^12.1.1",
    "expo-splash-screen": "~0.11.2",
    "expo-updates": "~0.10.13",
    "expo-web-browser": "~9.2.0",
    "format-string-by-pattern": "^1.2.1",
    "moment": "^2.24.0",
    "moment-range": "^4.0.2",
    "moment-timezone": "^0.5.28",
    "native-base": "^2.15.2",
    "react": "17.0.1",
    "react-native": "0.64.3",
    "react-native-actionsheet": "^2.4.2",
    "react-native-appearance": "~0.3.3",
    "react-native-calendar-picker": "^7.0.9",
    "react-native-calendars": "^1.263.0",
    "react-native-expo-image-cache": "^4.1.0",
    "react-native-gesture-handler": "~1.10.2",
    "react-native-keyboard-aware-scroll-view": "^0.9.1",
    "react-native-maps": "0.28.0",
    "react-native-markdown-display": "^6.0.1",
    "react-native-modal-datetime-picker": "^9.0.0",
    "react-native-open-maps": "^0.3.5",
    "react-native-reanimated": "~2.2.0",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "~3.4.0",
    "react-native-svg": "12.1.1",
    "react-native-swiper": "^1.6.0",
    "react-native-timeago": "^0.5.0",
    "react-native-webview": "11.6.2",
    "react-navigation": "4.4.4",
    "react-navigation-stack": "^2.10.4",
    "react-navigation-tabs": "^2.11.1",
    "react-redux": "^6.0.1",
    "redux": "^4.0.1",
    "redux-persist": "^6.0.0",
    "redux-thunk": "^2.3.0",
    "sentry-expo": "^4.0.0",
    "expo-status-bar": "~1.1.0",
    "react-dom": "17.0.1",
    "react-native-web": "0.17.1"
  },
  "devDependencies": {
    "babel-preset-expo": "8.3.0",
    "eslint": "^6.8.0",
    "eslint-config-universe": "^2.3.0",
    "eslint-plugin-react-redux": "^3.0.3",
    "prettier": "^1.19.1",
    "redux-logger": "^3.0.6",
    "@babel/core": "^7.12.9"
  },
  "private": true,
  "eslintConfig": {
    "settings": {
      "react": {
        "version": "detect"
      }
    },
    "extends": [
      "plugin:react-redux/recommended",
      "universe/native"
    ],
    "plugins": [
      "react-redux"
    ],
    "rules": {
      "react-redux/connect-prefer-named-arguments": 0,
      "react-redux/prefer-separate-component-file": 0
    }
  },
  "name": "mobile-v3",
  "version": "1.0.0"
}

Npm 7 introduced some changes in how dependencies are installed
Either downgrade node version via field node in eas.json to node 14 (it’s using npm 6) or fix your project to work with npm 7 or higher

Hi @joshua-splend

See also this answer from @brents for how to fix your project to work with npm >= 7.

1 Like

I added

        "eas-build-pre-install": "npm config set legacy-peer-deps true",

to the package.json and now the build works. One thing that confuses me a little is that I do have a yarn.lock file so I assume it’s using yarn instead of npm?

If you have both yarn.lock and package-lock.json you should pick one and delete the other one. If you pick yarn.lock, also get rid of that pre-install hook. You should probably also reinstall your dependencies to make sure they are as they should be. Also, you should not have the lock file in .gitignore.

So my build process was to run

yarn
eas build

However, I do have both the package-lock.json and yarn.lock in my .gitignore file. Does this mean that the eas build actually uses npm instead of yarn? Because this would explain why using the pre install hook fixed my build error.

I think so, yes. (EDIT: In this case.)

So what I would do is make sure you don’t have package-lock.json. If you do, remove it.
Remove yarn.lock from your .gitignore. Remove the pre-install hook.
Then it should work.

Does this mean that the eas build actually uses npm instead of yarn

If there is no lockfile in the repository eas defaults to npm, if there are both lockfiles it should use yarn. If a file is gitignored then it won’t be uploaded to eas.

1 Like

Thanks for the clarification, @wkozyra

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.