Skip to content

Commit ce51b62

Browse files
vitalyiegorovfacebook-github-bot
authored andcommitted
Fixed Android cliPath Gradle configuration option for build.gradle (#31839)
Summary: When using monorepo with react-native you need to provide `android/app/build.gradle` following params(`cliPath`): ``` project.ext.react = [ root: "../../../../", cliPath: "../../../../node_modules/react-native/cli.js", entryFile: "...", hermesCommand: "../../../../node_modules/hermes-engine/%OS-BIN%/hermesc" ] ``` With latest react-native `0.64.2` version you will get: ``` * What went wrong: Execution failed for task ':app:bundleReleaseJsAndAssets'. > Process 'command 'node'' finished with non-zero exit value 1 ``` Debugging this issue showed that providing `cliPath` options ends up building wrong path to cli: ``` > Task :app:bundleReleaseJsAndAssets FAILED node:internal/modules/cjs/loader:944 throw err; ^ Error: Cannot find module '/node_modules/react-native/cli.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15) at Function.Module._load (node:internal/modules/cjs/loader:774:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] } ``` Changed `react.gradle` for proper File creation for `cliPath` to support this configuration option. ## Changelog [Android] [Fixed] - Changed `react.gradle` `detectCliPath` function logic for `cliPath` case Pull Request resolved: #31839 Test Plan: Run `./gradlew assembleRelease` or `./gradlew assembleDebug` Reviewed By: yungsters Differential Revision: D30877674 Pulled By: sshic fbshipit-source-id: 26b75f8d29bf26b01630dde576b9052d0b94d89e
1 parent 05b449b commit ce51b62

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

react.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def detectEntryFile(config) {
2626
*/
2727
def detectCliPath(config) {
2828
if (config.cliPath) {
29-
return config.cliPath
29+
return "${projectDir}/${config.cliPath}"
3030
}
3131
if (new File("${projectDir}/../../node_modules/react-native/cli.js").exists()) {
3232
return "${projectDir}/../../node_modules/react-native/cli.js"

0 commit comments

Comments
 (0)