nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.35k stars 2.33k forks source link

EAS build fails for clean nx + expo app apparently due to missing dependencies, yet pre/post hooks run without issues #22195

Open rudfoss opened 6 months ago

rudfoss commented 6 months ago

Current Behavior

Running EAS build for an Expo app in a monorepo fails. The cause seems to be that the eas-build-pre-install and eas-build-post-install do not take effect correctly and the default package.json file in the app is used instead of the full one.

Expected Behavior

Eas build should work using a newly generated expo app in an Nx monorepo.

GitHub Repo

https://github.com/rudfoss/nx-expo-test

Steps to Reproduce

See readme of repro repo

  1. Create workspace

    pnpm create create-nx-workspace@latest nx-expo-test --workspaceType=integrated --nxCloud=skip --preset=apps --defaultBase=main
  2. Update .npmrc

    strict-peer-dependencies=false
    auto-install-peers=true
    node-linker=hoisted # added to ensure babel works
  3. Reinstall dependencies

    pnpm i
  4. Install expo plugin

    pnpm exec nx add @nx/expo
  5. Generate expo app

    pnpm exec nx generate @nx/expo:application --name=nx-expo-test --directory=apps/nx-expo-test --displayName=NxExpoTest --e2eTestRunner=playwright --projectNameAndRootFormat=as-provided --no-interactive
  6. Add eas-cli dependency

    pnpm add -D eas-cli
  7. Add eas project id and identifiers to app.json

    
    "ios": {
    "bundleIdentifier": "com.thr.nxexpotest"
    },

"android": { "package": "com.thr.nxexpotest" },

"extra": { "eas": { "projectId": "b9e09a49-29bb-459c-9984-1998087378b7" } }


8. Login and run EAS build for Android (generate new Android Keystore if prompted)
```bash
pnpm exec eas login
pnpm exec nx run nx-expo-test:build -- --platform android
  1. Build fails due to missing dependencies

Nx Report

NX   Report complete - copy this into the issue template

Node   : 20.9.0
OS     : win32-x64
pnpm   : 8.15.4

nx                 : 18.0.7
@nx/js             : 18.0.7
@nx/jest           : 18.0.7
@nx/linter         : 18.0.7
@nx/eslint         : 18.0.7
@nx/workspace      : 18.0.7
@nx/devkit         : 18.0.7
@nx/eslint-plugin  : 18.0.7
@nx/expo           : 18.0.7
@nx/playwright     : 18.0.7
@nx/react          : 18.0.7
@nrwl/tao          : 18.0.7
@nx/web            : 18.0.7
@nx/webpack        : 18.0.7
typescript         : 5.3.3

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

This might be an issue with the EAS build agents directly, but it is hard to debug as I cannot easily see the full file structure to determine if the package.json file is correct. The pre and post hooks seem to work without issues.

rudfoss commented 6 months ago

Issue open on expo-cli: https://github.com/expo/eas-cli/issues/2267

rudfoss commented 6 months ago

It appears that the .npmrc file is required for the installation on EAS to run correctly. Once I copied the .npmrc file to the nx-expo-test root folder the build works. Maybe that should also be part of the generator for pnpm-based repos?

.npmrc

strict-peer-dependencies=false
auto-install-peers=true
node-linker=hoisted

apps/nx-expo-test/package.json

Add && cp .npmrc apps/nx-expo-test to the end of the eas-build-pre-install script so that it is also copied along with the lock file.

{
  "name": "nx-expo-test",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "@testing-library/jest-native": "*",
    "@testing-library/react-native": "*",
    "metro-config": "*",
    "react-native": "*",
    "expo": "*",
    "react-native-svg": "*",
    "react-native-web": "*"
  },
  "scripts": {
    "eas-build-pre-install": "cd ../../ && node tools/scripts/eas-build-pre-install.mjs . apps/nx-expo-test && cp pnpm-lock.yaml apps/nx-expo-test && cp .npmrc apps/nx-expo-test",
    "eas-build-post-install": "cd ../../ && node tools/scripts/eas-build-post-install.mjs . apps/nx-expo-test"
  }
}
github-actions[bot] commented 5 days ago

This issue has been automatically marked as stale because it hasn't had any activity for 6 months. Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore. If at this point, this is still an issue, please respond with updated information. It will be closed in 21 days if no further activity occurs. Thanks for being a part of the Nx community! 🙏