Closed guillempuche closed 4 months ago
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.
Just fixed the Android prebuild issue!!!!!!! If you have the same problem as me, I think it will be solved in the following way
> 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
.
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.
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.
i created a pr to your repo: https://github.com/guillempuche/test-nx-expo/pull/1
what I did:
nx migrate latest
and migrate to nx version 19.2.3nx install expo
to verify the correct version of expo got installed"expo-modules-core": "*",
"expo-dev-launcher": "*",
"expo-dev-menu": "*",
"expo-json-menu": "*",
"expo-json-utils": "*",
"expo-manifests": "*",
"expo-asset": "*",
"expo-font": "*"
npx nx run expo:run-android
Works like a charm @xiongemi with React Native 0.74.2 and Expo 51.
Hope the app's package.json will much cleaner after https://github.com/nrwl/nx/pull/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>
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.
Current Behavior
After creating a new expo monorepo with Nx v19.1.1, Gradle throws an error.
The only thing I updated is some Expo packages like
@expo/cli
,expo-dev-client
...Expected Behavior
Build the app locally on my Android emulator.
Haven't tested on iOS.
GitHub Repo
https://github.com/guillempuche/test-nx-expo
Steps to Reproduce
app.json
(username and EAS id)npx nx run expo:run-android
Nx Report
Failure Logs
Package Manager Version
npm v10.1.0
Operating System
Additional Information
No response