Production build fails: unknown error (--legacy-peer-deps)

The same build request used to work but fails now. Here are the details-

BuildType: Expo managed, Android
SDK: 45
Node version: v16.18.1
NPM version: 8.19.2
EAS version: eas-cli/3.1.1

Due to npm package conflicts, locally I use the --legacy-peer-deps flag to run the app locally and works fine. Here is the build error from expo-

Running "npm install" in the root dir of your repository 
[stderr] npm
[stderr] WARN ERESOLVE overriding peer dependency
[stderr] npm WARN While resolving: @react-native-community/picker@1.8.1
[stderr] npm WARN Found: react@17.0.2
[stderr] npm WARN node_modules/react
[stderr] npm WARN   react@"17.0.2" from the root project
[stderr] npm WARN   31 more (@react-native-community/masked-view, ...)
[stderr] npm WARN
[stderr] npm WARN Could not resolve dependency:
[stderr] npm WARN peer react@"^16.0" from @react-native-community/picker@1.8.1
[stderr] npm WARN node_modules/@react-native-community/picker
[stderr] npm WARN   @react-native-community/picker@"^1.6.6" from react-native-phone-input@0.2.4
[stderr] npm WARN   node_modules/react-native-phone-input
[stderr] npm WARN 
[stderr] npm WARN Conflicting peer dependency: react@16.14.0
[stderr] npm WARN node_modules/react
[stderr] npm WARN   peer react@"^16.0" from @react-native-community/picker@1.8.1
[stderr] npm WARN   node_modules/@react-native-community/picker
[stderr] npm WARN     @react-native-community/picker@"^1.6.6" from react-native-phone-input@0.2.4
[stderr] npm WARN     node_modules/react-native-phone-input
[stderr] npm WARN ERESOLVE
[stderr] overriding peer dependency
[stderr] npm WARN While resolving: @react-native-community/viewpager@2.0.2
[stderr] npm WARN Found: react@17.0.2
[stderr] npm WARN node_modules/react
[stderr] npm WARN   react@"17.0.2" from the root project
[stderr] npm WARN   31 more (@react-native-community/masked-view, ...)
[stderr] npm WARN 
[stderr] npm WARN Could not resolve dependency:
[stderr] npm WARN peer react@"^16.0" from @react-native-community/viewpager@2.0.2
[stderr] npm WARN node_modules/@react-native-community/viewpager
[stderr] npm WARN   @react-native-community/viewpager@"^2.0.1" from react-native-scrollable-tab-view@1.0.0
[stderr] npm WARN   node_modules/react-native-scrollable-tab-view
[stderr] npm WARN 
[stderr] npm WARN Conflicting peer dependency: react@16.14.0
[stderr] npm WARN node_modules/react
[stderr] npm WARN   peer react@"^16.0" from @react-native-community/viewpager@2.0.2
[stderr] npm WARN   node_modules/@react-native-community/viewpager
[stderr] npm WARN     @react-native-community/viewpager@"^2.0.1" from react-native-scrollable-tab-view@1.0.0
[stderr] npm WARN     node_modules/react-native-scrollable-tab-view
[stderr] npm ERR! code
[stderr] ERESOLVE
[stderr] npm ERR! ERESOLVE could not resolve
[stderr] npm ERR! 
[stderr] npm ERR! While resolving: @react-navigation/compat@5.3.20
[stderr] npm ERR! Found: @react-navigation/native@6.1.1
[stderr] npm ERR! node_modules/@react-navigation/native
[stderr] npm ERR!   @react-navigation/native@"^6.0.10" from the root project
[stderr] npm ERR!   peer @react-navigation/native@"^6.0.0" from @react-navigation/bottom-tabs@6.5.2
[stderr] npm ERR!   node_modules/@react-navigation/bottom-tabs
[stderr] npm ERR!     @react-navigation/bottom-tabs@"^6.3.1" from the root project
[stderr] npm ERR!   4 more (@react-navigation/drawer, ...)
[stderr] npm ERR! 
[stderr] npm ERR! Could not resolve dependency:
[stderr] npm ERR! peer @react-navigation/native@"^5.0.5" from @react-navigation/compat@5.3.20
[stderr] npm ERR! node_modules/@react-navigation/compat
[stderr] npm ERR!   @react-navigation/compat@"^5.3.20" from the root project
[stderr] npm ERR! 
[stderr] npm ERR! Conflicting peer dependency: @react-navigation/native@5.9.8
[stderr] npm ERR! node_modules/@react-navigation/native
[stderr] npm ERR!   peer @react-navigation/native@"^5.0.5" from @react-navigation/compat@5.3.20
[stderr] npm ERR!   node_modules/@react-navigation/compat
[stderr] npm ERR!     @react-navigation/compat@"^5.3.20" from the root project
[stderr] npm ERR! 
[stderr] npm ERR! Fix the upstream dependency conflict, or retry
[stderr] npm ERR!
[stderr] 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-12-24T23_47_48_796Z-debug-0.log
npm exited with non-zero code: 1

It recommends running the same command with --legacy-peer-deps flag but there is no way to set that flag on the build command. How do I tell EAS to use this flag?

It worked without the flag before. No code change took place in between.

Hi @rparbez,

Here is how you can set --legacy-peer-deps flag for a build:

1 Like