nrwl / nx

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

Expo build command fails #20312

Open michal-cic opened 1 year ago

michal-cic commented 1 year ago

Current Behavior

The build command for an expo app fails, even with a fresh, barebones expo project.

Expected Behavior

I would like the build command to succeed.

GitHub Repo

https://github.com/michal-cic/nx-expo-issue-repro

Steps to Reproduce

  1. Create a new nx workspace with npx create-nx-workspace with the following options
    • Which stack do you want to use? None
    • Package-based monorepo, integrated monorepo, or standalone project? Package-based Monorepo
    • Enable distributed caching to make your CI faster No
  2. Move into the created folder
  3. Add @nx/expo with npm i --save-dev @nx/expo
  4. Generate new app with nx g @nx/expo:app my-app
  5. Run build command locally with npx nx build my-app -- --local (it fails without the local flag as well)
    • Select Android as the platform

Nx Report

npx nx report

 >  NX   Report complete - copy this into the issue template

   Node   : 16.19.1
   OS     : linux-x64
   npm    : 8.19.3

   nx                 : 17.1.2
   @nx/js             : 17.1.2
   @nx/jest           : 17.1.2
   @nx/linter         : 17.1.2
   @nx/eslint         : 17.1.2
   @nrwl/linter       : 16.10.0
   @nx/workspace      : 17.1.2
   @nx/detox          : 17.1.2
   @nx/devkit         : 17.1.2
   @nx/eslint-plugin  : 17.1.2
   @nx/expo           : 17.1.2
   @nx/react          : 17.1.2
   @nrwl/tao          : 17.1.2
   @nx/web            : 17.1.2
   @nx/webpack        : 17.1.2
   typescript         : 5.1.6
   ---------------------------------------
   The following packages should match the installed version of nx
     - @nrwl/linter@16.10.0

   To fix this, run `nx migrate nx@17.1.2`

Failure Logs

npx nx build my-app -- --local

> nx run my-app:build --local

★ eas-cli@5.9.0 is now available.
To upgrade, run npm install -g eas-cli.
Proceeding with outdated version.

✔ Select platform › Android
Loaded "env" configuration for the "production" profile: no environment variables specified. Learn more
✔ Using remote Android credentials (Expo server)
✔ Using Keystore from configuration: Build Credentials 9D0SwSEIl1 (default)
ANDROID_NDK_HOME environment variable was not specified, continuing build without NDK
[SETUP_WORKINGDIR] Preparing workingdir /tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f
[START_BUILD] Starting build
  "job": {
    "type": "managed",
    "platform": "android",
    "projectRootDirectory": "my-app",
    "projectArchive": {
      "type": "PATH",
      "path": "/tmp/michal/eas-cli-nodejs/2cfec783-3db1-4235-9a33-cecf9f669899.tar.gz"
    },
    "builderEnvironment": {},
    "cache": {
      "disabled": false,
      "paths": [],
      "clear": false
    },
    "updates": {},
    "buildType": "app-bundle",
    "username": "michal_cic",
    "experimental": {},
    "mode": "build",
    "triggeredBy": "EAS_CLI"
  }
[PRE_INSTALL_HOOK] Script 'eas-build-pre-install' is present in package.json, running it...
[PRE_INSTALL_HOOK] yarn run v1.22.19
[PRE_INSTALL_HOOK] $ cd ../ && node tools/scripts/eas-build-pre-install.mjs . my-app && cp package-lock.json my-app
[PRE_INSTALL_HOOK] Done in 0.06s.
[READ_PACKAGE_JSON] Using package.json:
[READ_PACKAGE_JSON] {
  "name": "my-app",
  "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 . my-app && cp package-lock.json my-app",
    "eas-build-post-install": "cd ../ && node tools/scripts/eas-build-post-install.mjs . my-app"
  }
}
[INSTALL_DEPENDENCIES] Running "npm install" in /tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app directory
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated @babel/plugin-proposal-optional-catch-binding@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated @babel/plugin-proposal-numeric-separator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
[INSTALL_DEPENDENCIES] npm WARN deprecated @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated @babel/plugin-proposal-export-namespace-from@7.18.9: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
[INSTALL_DEPENDENCIES] npm WARN
[INSTALL_DEPENDENCIES] deprecated @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated @babel/plugin-proposal-async-generator-functions@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
[INSTALL_DEPENDENCIES] npm WARN
[INSTALL_DEPENDENCIES] deprecated @babel/plugin-proposal-object-rest-spread@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
[INSTALL_DEPENDENCIES] npm WARN
[INSTALL_DEPENDENCIES] deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
[INSTALL_DEPENDENCIES] npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
[INSTALL_DEPENDENCIES] npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
[INSTALL_DEPENDENCIES] npm WARN
[INSTALL_DEPENDENCIES] deprecated uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
[INSTALL_DEPENDENCIES] npm ERR! code 1
[INSTALL_DEPENDENCIES] npm ERR! path /tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx
[INSTALL_DEPENDENCIES] npm ERR!
[INSTALL_DEPENDENCIES] command failed
[INSTALL_DEPENDENCIES] npm ERR! command sh -c -- node ./bin/post-install
[INSTALL_DEPENDENCIES] npm ERR! node:internal/modules/cjs/loader:1024
[INSTALL_DEPENDENCIES] npm ERR!   throw err;
[INSTALL_DEPENDENCIES] npm ERR!   ^
[INSTALL_DEPENDENCIES] npm ERR! 
[INSTALL_DEPENDENCIES] npm ERR! Error: Cannot find module 'nx/presets/npm.json'
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] ERR! Require stack:
[INSTALL_DEPENDENCIES] npm ERR! - /tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/src/config/nx-json.js
[INSTALL_DEPENDENCIES] npm ERR! - /tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/src/config/workspaces.js
[INSTALL_DEPENDENCIES] npm ERR! - /tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/src/utils/nx-plugin.js
[INSTALL_DEPENDENCIES] npm ERR! - /tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/src/project-graph/build-project-graph.js
[INSTALL_DEPENDENCIES] npm ERR! - /tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/src/project-graph/project-graph.js
[INSTALL_DEPENDENCIES] npm ERR! - /tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/bin/post-install.js
[INSTALL_DEPENDENCIES] npm ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1021:15)
[INSTALL_DEPENDENCIES] npm ERR!     at Function.resolve (node:internal/modules/cjs/helpers:114:19)
[INSTALL_DEPENDENCIES] npm ERR!     at readNxJson (/tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/src/config/nx-json.js:13:48)
[INSTALL_DEPENDENCIES] npm ERR!     at Object.<anonymous> (/tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/src/daemon/client/client.js:319:72)
[INSTALL_DEPENDENCIES] npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1191:14)
[INSTALL_DEPENDENCIES] npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1245:10)
[INSTALL_DEPENDENCIES] npm ERR!     at Module.load (node:internal/modules/cjs/loader:1069:32)
[INSTALL_DEPENDENCIES] npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:904:12)
[INSTALL_DEPENDENCIES] npm ERR!     at Module.require (node:internal/modules/cjs/loader:1093:19)
[INSTALL_DEPENDENCIES] npm ERR!     at require (node:internal/modules/cjs/helpers:108:18) {
[INSTALL_DEPENDENCIES] npm ERR!   code: 'MODULE_NOT_FOUND',
[INSTALL_DEPENDENCIES] npm ERR!   requireStack: [
[INSTALL_DEPENDENCIES] npm ERR!     '/tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/src/config/nx-json.js',
[INSTALL_DEPENDENCIES] npm ERR!     '/tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/src/config/workspaces.js',
[INSTALL_DEPENDENCIES] npm ERR!     '/tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/src/utils/nx-plugin.js',
[INSTALL_DEPENDENCIES] npm ERR!     '/tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/src/project-graph/build-project-graph.js',
[INSTALL_DEPENDENCIES] npm ERR!     '/tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/src/project-graph/project-graph.js',
[INSTALL_DEPENDENCIES] npm ERR!     '/tmp/michal/eas-build-local-nodejs/d8cd5ac0-fc72-4c05-95c1-4ce1e786959f/build/my-app/node_modules/@nx/react/node_modules/nx/bin/post-install.js'
[INSTALL_DEPENDENCIES] npm ERR!   ]
[INSTALL_DEPENDENCIES] npm ERR! }
[INSTALL_DEPENDENCIES] npm ERR! A complete log of this run can be found in:
[INSTALL_DEPENDENCIES] npm ERR!     /home/michal/.npm/_logs/2023-11-17T14_59_02_532Z-debug-0.log
[INSTALL_DEPENDENCIES] 
Error: npm install exited with non-zero code: 1
    at ChildProcess.completionListener (/home/michal/.npm/_npx/81e2a4b8a789d5cc/node_modules/@expo/spawn-async/build/spawnAsync.js:42:23)
    at Object.onceWrapper (node:events:628:26)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
    ...
    at spawnAsync (/home/michal/.npm/_npx/81e2a4b8a789d5cc/node_modules/@expo/spawn-async/build/spawnAsync.js:7:23)
    at spawn (/home/michal/.npm/_npx/81e2a4b8a789d5cc/node_modules/@expo/turtle-spawn/dist/index.js:16:47)
    at installDependenciesAsync (/home/michal/.npm/_npx/81e2a4b8a789d5cc/node_modules/@expo/build-tools/dist/common/installDependencies.js:23:38)
    at /home/michal/.npm/_npx/81e2a4b8a789d5cc/node_modules/@expo/build-tools/dist/common/setup.js:50:66
    at BuildContext.runBuildPhase (/home/michal/.npm/_npx/81e2a4b8a789d5cc/node_modules/@expo/build-tools/dist/context.js:101:34)
    at setupAsync (/home/michal/.npm/_npx/81e2a4b8a789d5cc/node_modules/@expo/build-tools/dist/common/setup.js:49:15)
    at async buildAsync (/home/michal/.npm/_npx/81e2a4b8a789d5cc/node_modules/@expo/build-tools/dist/builders/android.js:38:5)
    at async runBuilderWithHooksAsync (/home/michal/.npm/_npx/81e2a4b8a789d5cc/node_modules/@expo/build-tools/dist/builders/common.js:12:13)
    at async Object.androidBuilder (/home/michal/.npm/_npx/81e2a4b8a789d5cc/node_modules/@expo/build-tools/dist/builders/android.js:24:16)
    at async buildAndroidAsync (/home/michal/.npm/_npx/81e2a4b8a789d5cc/node_modules/eas-cli-local-build-plugin/dist/android.js:66:12)

Build failed
Unknown error. See logs of the Install dependencies build phase for more information.
npx exited with non-zero code: 1
    Error: build command failed.

 >  NX   1

 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target build for project my-app (41s)

         With additional flags:
           --local=true

    ✖    1/1 failed
    ✔    0/1 succeeded [0 read from cache]

Package Manager Version

No response

Operating System

Additional Information

I have noticed that the script eas-build-pre-install.mjs, that runs before installing dependencies (and other build steps) is supposed to copy dependencies and devDependencies from the workspace root package.json to the project root package.json (and also copy the workspace root package-lock.json to the project root). However, this doesn't seem to work and the project root package.json stays unchanged. I'm not sure how to proceed from here, I will be very happy for any pointers, thanks in advance.

github-actions[bot] commented 2 weeks 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! 🙏