Giter VIP home page Giter VIP logo

Comments (6)

xiongemi avatar xiongemi commented on August 26, 2024 1

i created a pr to your repo: guillempuche/test-nx-expo#1

what I did:

  • I run nx migrate latest and migrate to nx version 19.2.3
  • I run nx install expo to verify the correct version of expo got installed
  • in expo's package.json, explicitly add apps/expo/package.json:
    "expo-modules-core": "*",
    "expo-dev-launcher": "*",
    "expo-dev-menu": "*",
    "expo-json-menu": "*",
    "expo-json-utils": "*",
    "expo-manifests": "*",
    "expo-asset": "*",
    "expo-font": "*"
  • delete apps/expo/android folder and run npx nx run expo:run-android

from nx.

milk717 avatar milk717 commented on August 26, 2024

I'm experiencing the same problem.
I'm using yarn workspace but I can't do android prebuild.
The following error occurs.

Script '/Users/user/myProject-name/node_modules/expo-modules-core/android/ExpoModulesCorePlugin.gradle' line: 85

* * What went wrong:
A problem occurred configuring project ':expo'.
> Could not get unknown property 'release' for SoftwareComponent container of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

Migrating the same project to a single repo rather than a monorepo will cause prebuild to operate normally.
It runs well in the development phase because I looked at the https://docs.expo.dev/guides/monorepos/ document and set the appropriate metro.config setting and manual index.ts entry point.

But I can't just do prebuild.
I've been suffering for three days.
Does anyone know the solution??

FYI, I'm using the exposdk 51 version, but the same problem occurs with the sdk 50 version.

from nx.

milk717 avatar milk717 commented on August 26, 2024

Just fixed the Android prebuild issue!!!!!!!
If you have the same problem as me, I think it will be solved in the following way

Why it didn't build

Error that occurred

> Configure project :expo
Evaluating project ':expo' using build file '/Users/user/WebstormProjects/healthcare-assistant-frontend/node_modules/expo/android/build.gradle'.
Using default execution profile
Starting process 'command 'node''. Working directory: /Users/user/WebstormProjects/healthcare-assistant-frontend/services/chatbot-app/android Command: node --print require.resolve('expo-modules-autolinking/package.json', { paths: [require.resolve('expo/package.json')] })
Successfully started process 'command 'node''
Using Kotlin Gradle Plugin gradle82 variant
Starting process 'command 'node''. Working directory: /Users/user/WebstormProjects/healthcare-assistant-frontend/node_modules/expo/android Command: node -e console.log(require('react-native/package.json').version);
Successfully started process 'command 'node''
Could not execute [report metric STATISTICS_COLLECT_METRICS_OVERHEAD]
Could not execute [report metric STATISTICS_COLLECT_METRICS_OVERHEAD]

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* * Where:
Build file '/Users/user/WebstormProjects/healthcare-assistant-frontend/node_modules/expo/android/build.gradle' line: 17

* * What went wrong:
A problem occurred evaluating project ':expo'.
> Process 'command 'node'' finished with non-zero exit value 1

Expo gets the version of react-native by referring to react-native/package.json in node_modules in the prebuild process.

The phrase 'build.gradle' in that part is:

def getRNVersion() {
  def nodeModulesVersion = providers.exec {
    workingDir(projectDir)
    commandLine("node", "-e", "console.log(require('react-native/package.json').version);")
  }.standardOutput.asText.get().trim()

  def version = safeExtGet("reactNativeVersion", nodeModulesVersion)
  def coreVersion = version.split("-")[0]
  def (major, minor, patch) = coreVersion.tokenize('.').collect { it.toInteger() }

  return versionToNumber(
      major,
      minor,
      patch
  )
}

The version is being imported by setting workingDir to projectDir. However, in the current project, the dependencies related to Expo are installed on the root node_modules, while the dependencies related to react-native are installed on myproject-expo/node_modules. Therefore, it is expected that there was a problem getting the path. Work with morepos - Expo Documentation seems to have set up the environment assuming that the react-native package is installed on the root. Therefore, we fixed the problem by explicitly installing react-native on the root node_modules.

Why was the react-native dependency installed inside the package and not installed in root?

If you use Yarn Workspaces monorepo, most of the dependencies are hoisted and installed in the root node_modules. However, if different versions of the same dependencies are used in multiple workspaces, they are also installed in node_modules inside each package.

Yes) Package A uses the react 17 version, and Package B uses the react 18 version

If you look at react-native 0.74.1 package.json , react is fixed in the peerDependences part. However, the current version of react used in the myproject-web package is set to ^18, and accordingly, the latest version of react of 18 or later has been installed, and this version is 18.3.1. Therefore, the react-native version required by the react-native package is different from the version of react currently installed in the workspace, so react-native is installed as an individual dependency of the package, not the root. Currently the latest package.json in the react-native repository has changed peerDependencies to ^18.2.0, so the next version of react-native is likely to resolve this issue.

from nx.

guillempuche avatar guillempuche commented on August 26, 2024

Fantastic @milk717! Thanks for the explanation, good learning for me. Waiting for the next release.

Expo and Nx is causing multiple problems explained here https://github.com/guillempuche/nx-expo-next-tamagui?tab=readme-ov-file#known-issues, and the benefit of using Expo CLI (yarn expo ..., npx expo ...). I'm splitting both worlds for now, https://github.com/guillempuche/nx-monorepo-with-expo-standalone-app.

from nx.

guillempuche avatar guillempuche commented on August 26, 2024

Works like a charm @xiongemi with React Native 0.74.2 and Expo 51.

Hope the app's package.json will much cleaner after #26086.

For the rest of people, apart from some Android folder changes, Emily modified the package.json to:

{
  "name": "expo",
  "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": "*",
    "expo-dev-client": "~3.3.12",
    "react": "18.2.0",
    "expo-modules-core": "*",
    "expo-dev-launcher": "*",
    "expo-dev-menu": "*",
    "expo-json-menu": "*",
    "expo-json-utils": "*",
    "expo-manifests": "*",
    "expo-asset": "*",
    "expo-font": "*"
  },
  "scripts": {
    "eas-build-pre-install": "cd ../../ && node tools/scripts/eas-build-pre-install.mjs . apps/expo && cp package-lock.json apps/expo",
    "eas-build-post-install": "cd ../../ && node tools/scripts/eas-build-post-install.mjs . apps/expo",
    "android": "expo run:android",
    "ios": "expo run:ios"
  }
}

@xiongemi, how Expo CLI https://docs.expo.dev/more/expo-cli/ can work with Nx?

For example, Expo knows what dependency version to install for compatibility, npx expo install <expo_package>

from nx.

github-actions avatar github-actions commented on August 26, 2024

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

from nx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.