react-native: JS Bundle Error after upgrading to 0.70.1.
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:
- followed
react-native community upgrade helper
instruction strictly two times. - did
yarn start --reset-cache
- did
cd android && ./gradlew clean && cd ..
- did
yarn android
- building looks fine without any errors
- after Gradle task
installDebug
- got those errors above
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 19 (2 by maintainers)
For me the problem was in
metro.config.js
. Lines 9-11 caused the problem.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 withapp.json
.@SectionTN I see similar config in your repo, so I think you can try fixing your project by adding
json
to the array.thanks adding
json
fixed my problemso add
json
extension therere-upgraded again and encountered the same issue
Can you provide a reproducer?