EAS build failing in monorepo

I have an expo native app inside a monorepo managed with Lerna and yarn workspaces these are the details:

  • Node v 16.15.1
  • Yarn v 3.2.2
  • Expo sdk 45 - Semi-bare workflow (using plugins, but it doesn’t work also when getting rid of the plugins and trying to compile as a fully managed app)
  • expo-cli v 6.0.2
  • eas-cli v 0.59.0

this is the error I get after running eas build --clear-cache --profile=staging --local.

We detected that 'packages/breinapp-rn' is a yarn workspace
Running "yarn install --no-immutable" in the root dir of your repository 
[many lines of logs later...]
[RUN_FASTLANE] › Packaging @react-native-async-storage/async-storage Pods/RNCAsyncStorage » libRNCAsyncStorage.a
[RUN_FASTLANE] › Packaging react-native Pods/RCTTypeSafety » libRCTTypeSafety.a
[RUN_FASTLANE] › Executing react-native Pods/FBReactNativeSpec » [CP-User] Generate Specs
[RUN_FASTLANE] 
❌  error: Could not determine react-native-codegen location in /var/folders/cz/sj8s_yqd6_90pd24j7j71lb40000gn/T/eas-build-local-nodejs/7eb4bae1-850a-4802-a346-a6953213bf91/build/packages/breinapp-rn/ios/Pods/../../node_modules/react-native/React/FBReactNativeSpec/../../packages/react-native-codegen or /var/folders/cz/sj8s_yqd6_90pd24j7j71lb40000gn/T/eas-build-local-nodejs/7eb4bae1-850a-4802-a346-a6953213bf91/build/packages/breinapp-rn/ios/Pods/../../node_modules/react-native/React/FBReactNativeSpec/../../../react-native-codegen. Try running 'yarn install' or 'npm install' in your project root.

when running a cloud build (without the --local param) i get this error instead:

Running "expo doctor"
[stderr] [21:05:56] Cannot determine which native SDK version your project uses because the module `expo` is not installed. Please install it with `yarn add expo` and try again.
Command "expo doctor" failed.bash exited with non-zero code: 1

and

Installing pods
[stderr] node:internal/modules/cjs/loader:936
[stderr]   throw err;
[stderr]   ^
[stderr] 
[stderr] Error: Cannot find module 'expo/package.json'
[stderr] Require stack:
[stderr] - /Users/expo/workingdir/build/packages/breinapp-rn/ios/[eval]
[stderr]     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
[stderr]     at Function.resolve (node:internal/modules/cjs/helpers:108:19)
[stderr]     at [eval]:1:9
[stderr]     at Script.runInThisContext (node:vm:129:12)
[stderr]     at Object.runInThisContext (node:vm:305:38)
[stderr]     at node:internal/process/execution:75:19
[stderr]     at [eval]-wrapper:6:22
[stderr]     at evalScript (node:internal/process/execution:74:60)
[stderr]     at node:internal/main/eval_string:27:3 {
[stderr]   code: 'MODULE_NOT_FOUND',
[stderr]   requireStack: [
[stderr]     '/Users/expo/workingdir/build/packages/breinapp-rn/ios/[eval]'
[stderr]   ]
[stderr] }
[!] Invalid `Podfile` file: cannot load such file -- ./scripts/autolinking.
 #  from /Users/expo/workingdir/build/packages/breinapp-rn/ios/Podfile:1
 #  -------------------------------------------
 >  require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
 #  require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
 #  -------------------------------------------
pod exited with non-zero code: 1

expo prebuild, expo run:ios work fine and expo doctor doesn’t report any issue, I have also applied the configuration described here: Working with Monorepos - Expo Documentation

if I copy the expo app out of the monorepo and try a “standalone” build it works fine instead…
any idea on what can I do to resolve this issue?

Hi @brein, can you please share the JSON of top-level and app-level package.json files in your project? There is a chance that there might be a dependency that is not installed correctly. We tried following our own example and couldn’t reproduce it.