I have recently made an app and I am trying to build it for TestFlight.
in my app I started using
react-native-svg-charts which uses react-native-svg.
these are the version in my package.json:
"react-native-svg": "^15.3.0",
"react-native-svg-charts": "^5.4.0",
"react-native-chart-kit": "^6.12.0",
when I do npx expo start, I can see my app runs and its alright, when I do:
eas build –platform iOS
then the build fails because:
Running "npm install" in /Users/expo/workingdir/build directory
npm
ERR! code ERESOLVE
npm ERR!
ERESOLVE could not resolve
npm ERR!
npm
ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react-native-svg
npm ERR! react-native-svg@"^15.3.0" from the root project
npm ERR! peer react-native-svg@"> 6.4.1" from [email protected]
npm ERR! node_modules/react-native-chart-kit
npm ERR! react-native-chart-kit@"^6.12.0" from the root project
npm ERR! 1 more (react-native-gifted-charts)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native-svg@"^6.2.1||^7.0.3" from [email protected]
npm ERR! node_modules/react-native-svg-charts
npm ERR! react-native-svg-charts@"^5.4.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm
ERR! node_modules/react-native-svg
npm ERR! peer react-native-svg@"^6.2.1||^7.0.3" from [email protected]
npm ERR! node_modules/react-native-svg-charts
npm ERR! react-native-svg-charts@"^5.4.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/expo/.npm/_logs/2024-06-16T18_10_33_225Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in: /Users/expo/.npm/_logs/2024-06-16T18_10_33_225Z-debug-0.log
npm install exited with non-zero code: 1
when I do npm install I get:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react-native-svg
npm ERR! react-native-svg@"^15.3.0" from the root project
npm ERR! peer react-native-svg@"> 6.4.1" from [email protected]
npm ERR! node_modules/react-native-chart-kit
npm ERR! react-native-chart-kit@"^6.12.0" from the root project
npm ERR! 1 more (react-native-gifted-charts)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native-svg@"^6.2.1||^7.0.3" from [email protected]
npm ERR! node_modules/react-native-svg-charts
npm ERR! react-native-svg-charts@"^5.4.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react-native-svg
npm ERR! peer react-native-svg@"^6.2.1||^7.0.3" from [email protected]
npm ERR! node_modules/react-native-svg-charts
npm ERR! react-native-svg-charts@"^5.4.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/niloufar/.npm/_logs/2024-06-16T18_14_27_517Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in: /Users/niloufar/.npm/_logs/2024-06-16T18_14_27_517Z-debug-0.log
so there are some dependency issues, if I do this:
npm uninstall react-native-svg
npm i [email protected]
then I can do npm install, but when I do npx expo start, then I get :
Invariant Violation: "main" has not been registered. This can happen if: * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project. * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
I am running out of idea I don’t know what to do, no matter what I do I get some error.
DO I need to not use the react-native-svg-charts?
Please help me out.
2
Answers
this error occurs because the is already an existing version of [email protected]. So first uninstall it.
npm uninstall react-native-svg
and remove the react-native-svg from
package.json
file and try installing it again with the required versionnpm install [email protected]
also try running
npm install expo-doctor@latest
npx expo-doctor
to check for any dependency conflict..
Hope this answer resolves your issue
You have resolved the dependency conflict correctly, however something else is preventing app from running and causing "Invariant Violation".
I would advice clearing metro cache, reinstalling dependencies, restarting metro and running the app again, while carefully checking metro logs and device logs. You should see an error happening before the Invariant Violation.
If you confirm that the error is caused by
[email protected]
, you could try using a newer version:react-native-svg@^7.0.3
or v6:react-native-svg@^6.2.1