I upgraded my RN project from 0.71.12 to 0.75.2 and I’m able to run both Android and iOS project in my local. For the app release I’m able to build and deliver Android project to Google Play Console by using App Center but for the iOS project I get errors like this from App Center iOS pipeline:
[command]/bin/bash --noprofile --norc /Users/runner/work/_temp/db95f9b0-01e7-4cb3-
bd0d-4970e0cd7b11.sh
Found index.js for ReactNative index.
node:internal/modules/cjs/loader:1143
throw err;
^
Error: Cannot find module '/Users/runner/work/1/s/apps/mobile/node_modules/react-
native/local-cli/cli.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
at Module._load (node:internal/modules/cjs/loader:981:27)
at Function.executeUserEntryPoint [as runMain]
(node:internal/modules/run_main:128:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v18.20.4
Does anyone have an idea where the issue might come from?
My project is a mono repo containing a React project and a React Native one.
2
Answers
I spend the entire day yesterday trying to figure out a solution and landed on a somewhat basic (and maybe hacky) solution but it worked.
The problem was that since RN 0.75.0 the
/local-cli/cli.js
file is no longer available but AppCenter is expecting it. I simply re-added thiscli.js
file using https://www.npmjs.com/package/patch-package.This resulted in the following `packages/react-native+0.75.2.patch file:
After this the build succeeded. Hope this helps.
This problem is related to
appcenter-cli
which is being installed globally inside ourUsers/<username>/AppData/Roaming/nvm/<your-node-version>/node_modules/appcenter-cli/dist/commands/codepush/lib/react-native-utils.js
. Here is a method presentgetCliPath
where it is mentioned to addlocal-cli
as a path. But recent react-native 0.75.0 or above this path is removed. So just removing this path should work.