React native bundleRelease task fails with error "The resource `index.js` was not found on a monorepo after upgrade from react-native 0.66.0 to 0.68.2

1.4k views Asked by At

I have a mobile app and a web app for the same application and I use yarn workspaces monorepo to manage the two and the shared code in various packages. I have running this setup for a few months now successfully. I needed to make changes to same config files to get it work but it has been working very well till now.

Today, I updated from react-native 0.66.0 to 0.68.2. I made all the required changes and I am able to run the app in debug mode on iOS and Android. I am also able to build the iOS app successfully. But on Android, I am running into the following error:

warning: the transform cache was reset.
error The resource `/Users/username/Projects/myapp-monorepo/index.js` was not found.
Error: The resource `/Users/username/Projects/myapp-monorepo/index.js` was not found.
    at /Users/username/Projects/myapp-monorepo/node_modules/metro/src/IncrementalBundler.js:297:24
    at gotStat (node:fs:2654:21)
    at FSReqCallback.oncomplete (node:fs:198:21)
info Run CLI with --verbose flag for more details.

> Task :app:bundleReleaseJsAndAssets FAILED

> Task :app:[email protected]+7340962_7340962 FAILED
  INFO    2022-05-30 19:23:40.400504 +05:30 Loaded config from /Users/username/.sentryclirc
  DEBUG   2022-05-30 19:23:40.401302 +05:30 sentry-cli version: 1.74.4, platform: "darwin", architecture: "x86_64"
  INFO    2022-05-30 19:23:40.401310 +05:30 sentry-cli was invoked with the following command line: "/Users/username/Projects/myapp-monorepo/node_modules/@sentry/cli/sentry-cli" "--log-level" "debug" "react-native" "gradle" "--bundle" "/Users/username/Projects/myapp-monorepo/packages/GalarmApp/android/app/build/generated/assets/react/release/index.android.bundle" "--sourcemap" "/Users/username/Projects/myapp-monorepo/packages/GalarmApp/android/app/build/generated/sourcemaps/react/release/index.android.bundle.map" "--release" "[email protected]+7340962" "--dist" "7340962"
error: An organization slug is required (provide with --org)
  DEBUG   2022-05-30 19:23:40.401360 +05:30 skipping update nagger because session is not attended

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'node'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:[email protected]+7340962_7340962'.
> Process 'command '/Users/username/Projects/myapp-monorepo/node_modules/@sentry/cli/bin/sentry-cli'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

As you can see, it is trying to access /Users/username/Projects/myapp-monorepo/index.js and not finding it which of course the file is not there. The file is located in the app monorepo at location /Users/username/Projects/myapp-monorepo/packages/myapp/index.js.

I am not sure where is this coming from so I can fix the corresponding config file. It seems to be related to metro, Sentry and the release build task.

I am totally stuck due to this problem. If you have any pointers, please share.

1

There are 1 answers

0
EvoluWil On

if anyone is still looking for this answer

the error is

index.js file not found

this happens when we change the index.js file name to index.jsx or index.tsx

to resolve just change the name back to index.js