Unable to resolve module error using EAS Build in a monorepo

In your post, please share:

  • Whether you are bare or managed workflow
    Managed

  • Your eas-cli version
    5.2.0

  • What you have tried so far
    I have a monorepo that is structured the same way the Expo monorepo guide shows, but for some reason when I try to build the app it is not able to resolve the modules from our packages. It is replacing the alias with two too many ../'s.
    error Unable to resolve module ../../../../packages/app/navigation/native
    When it’s only two directories higher, just like the app structure in the guide.
    I also get these errors

[RUN_GRADLEW]   * ../../packages/app/navigation/native(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
[RUN_GRADLEW]   * ../../packages/app/navigation/native/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)

Which seems to show a different path for the module resolution.

I took a look at the build folder by passing EAS_LOCAL_BUILD_SKIP_CLEANUP=1 and the files are all there in the correct location.

The directory structure is as follows:

root
_packages
__app
___navigation
____native
_apps
__expo
___App.js (Where the module is being imported)

How can I fix this?

hi there! check out this guide that explains how the archive that is uploaded to eas build is created: https://expo.fyi/eas-build-archive

one thing to look out for here is whether you possibly have committed files to git using a different case, eg: MyFile.tsx vs myFile.tsx

Hi brents, thanks for the reply!

I’ve been building it locally though, and looking at the copied build I see all the files there with the same names as in the original. We haven’t committed files with different names/casing.

can you try doing a fresh clone of your repository to a new directory?

While I was doing that and fixing little config issues that needed to be fixed to get to the same point I was in the first repo, I realized the babel.config.js’s module resolver was resolving two directories higher than it needed to because I had moved it from the nested expo folder to the root directory. So it didn’t directly fix the issue but helped me realize what was breaking it, thanks!

1 Like