JS Bundle Error after upgrading to 0.70.1.

This issue has been tracked since 2022-09-16.

New Version

0.70.1

Old Version

0.69.5

Build Target(s)

android debug and maybe release too

Output of react-native info

info Fetching system and libraries information...
System:
    OS: Linux 5.19 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (4) x64 Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz
    Memory: 1.05 GB / 3.72 GB
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.9.0 - /snap/bin/node
    Yarn: 1.22.19 - /snap/bin/yarn
    npm: 8.19.1 - /snap/bin/npm
    Watchman: Not Found
  SDKs:
    Android SDK:
      API Levels: 29, 30, 31, 32, 33
      Build Tools: 29.0.2, 30.0.3, 31.0.0, 32.0.0, 33.0.0
      Android NDK: Not Found
  IDEs:
    Android Studio: AI-212.5712.43.2112.8815526
  Languages:
    Java: 1.8.0_342 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.70.1 => 0.70.1 
  npmGlobalPackages:
    *react-native*: Not Found

Issue and Reproduction Steps

My issue is no library has been detected after the upgrade, for example:

error: Error: Unable to resolve module react-native-onesignal from /home/section/Documents/GitHub/MoonMeet-CrossPlatform/index.js: react-native-onesignal could not be found within the project or in these directories:
  node_modules
  ../../../node_modules
   7 |  */
   8 | import {AppRegistry} from 'react-native';
>  9 | import OneSignal from 'react-native-onesignal';                                                                                                        
     |                        ^
  10 | import App from './App';
  11 | import {name as MoonMeet} from './app.json';
  12 | import {ONESIGNAL_APP_ID} from './src/secrets/sensitive';
    at ModuleResolver.resolveDependency (/home/section/Documents/GitHub/MoonMeet-CrossPlatform/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:178:15)
    at DependencyGraph.resolveDependency (/home/section/Documents/GitHub/MoonMeet-CrossPlatform/node_modules/metro/src/node-haste/DependencyGraph.js:264:43)
    at Object.resolve (/home/section/Documents/GitHub/MoonMeet-CrossPlatform/node_modules/metro/src/lib/transformHelpers.js:170:21)
    at resolveDependencies (/home/section/Documents/GitHub/MoonMeet-CrossPlatform/node_modules/metro/src/DeltaBundler/graphOperations.js:466:33)
    at processModule (/home/section/Documents/GitHub/MoonMeet-CrossPlatform/node_modules/metro/src/DeltaBundler/graphOperations.js:232:31)
    at async traverseDependenciesForSingleFile (/home/section/Documents/GitHub/MoonMeet-CrossPlatform/node_modules/metro/src/DeltaBundler/graphOperations.js:221:3)
    at async Promise.all (index 0)
    at async initialTraverseDependencies (/home/section/Documents/GitHub/MoonMeet-CrossPlatform/node_modules/metro/src/DeltaBundler/graphOperations.js:204:3)
    at async DeltaCalculator._getChangedDependencies (/home/section/Documents/GitHub/MoonMeet-CrossPlatform/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:208:25)
    at async DeltaCalculator.getDelta (/home/section/Documents/GitHub/MoonMeet-CrossPlatform/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:90:16)

if I comment (//) OneSignal and Notifee codes, I got ./app.json is not found :/ which is 100000% inside my root project folder.
I'm pretty sure it's a wrong node modules folder or something, when i rollback to 0.69.5 my application works fine

steps:

  1. followed react-native community upgrade helper instruction strictly two times.
  2. did yarn start --reset-cache
  3. did cd android && ./gradlew clean && cd ..
  4. did yarn android
  5. building looks fine without any errors
  6. after Gradle task installDebug
  7. got those errors above
SectionTN wrote this answer on 2022-09-16

any updates on this?
also why is the directory ../../../node_modules, i think it's wrong.

marceloch2 wrote this answer on 2022-09-18

I have the same for IOS.

SectionTN wrote this answer on 2022-09-18

i hope someone finds a solution.

SectionTN wrote this answer on 2022-09-20

@cortinico (sorry for the ping without your permission) could you check this issue please?

cortinico wrote this answer on 2022-09-20

@cortinico (sorry for the ping with your permission) could you check this issue please?

Can you provide a reproducer?

SectionTN wrote this answer on 2022-09-21

I did init a new React Native Project 0.70.1, nothing went wrong with the bundler, but it's not working with my project, could you try to run this, repo link, choose branch upgrade/RN70.1

cortinico wrote this answer on 2022-09-21

I did init a new React Native Project 0.70.1, nothing went wrong with the bundler, but it's not working with my project, could you try to run this, repo link, choose branch upgrade/RN70.1

I could not build your project @SectionTN. A simple yarn && yarn android fails with:

> Could not resolve all files for configuration ':react-native-clipboard_clipboard:classpath'.
   > Could not download builder-3.2.1.jar (com.android.tools.build:builder:3.2.1)
      > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.2.1/builder-3.2.1.jar'.

As you're depending on react-native-clipboard which is on AGP 3 (which is quite of an old version) and can't be resolved anymore. Your project is also full of dependencies making hard to pinpoint the problem. Can you create a smaller reproducer?

SectionTN wrote this answer on 2022-09-21

Yes my project depending on react-native-clipboard/clipboard package.

i can build my project on linux / windows without problems, idk why it's showing you a build error there.

i have did npx react-native init Project and tried building, nothing went wrong on a fresh project, as you said it's hard to find the problem here, I'll add any comment may help resolving this problem if possible.

PS: the build is passing on the Android CI workflow.

SectionTN wrote this answer on 2022-09-22

re-upgraded again and encountered the same issue Screenshot_20220921-175922_Moon Meet.png

AliMamed wrote this answer on 2022-09-27

For me the problem was in metro.config.js.
Снимок экрана 2022-09-27 в 13 45 01
Lines 9-11 caused the problem.

  resolver: {
    sourceExts: ['jsx', 'js', 'ts', 'tsx'],
  },

Adding json extension to the array solved the problem. I must admit that the error reporting for me was also confusing: I had the errors of resolving other modules rather than anything wrong with app.json.

@SectionTN I see similar config in your repo, so I think you can try fixing your project by adding json to the array.

SectionTN wrote this answer on 2022-09-27

Screenshot_20220927-121223_GitHub.png
already have this config inside my metro config

AliMamed wrote this answer on 2022-09-27

already have this config inside my metro config

so add json extension there

SectionTN wrote this answer on 2022-09-28

thanks adding json fixed my problem

More Details About Repo
Owner Name facebook
Repo Name react-native
Full Name facebook/react-native
Language JavaScript
Created Date 2015-01-09
Updated Date 2022-10-03
Star Count 105144
Watcher Count 3666
Fork Count 22469
Issue Count 2232

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date