react-native-svg: Ambiguous resolution
Hello,
after upgrading react-native to the latest RC, bundling fails together with react-native-svg:
Bundling `index.android.js` [development, non-minified, hmr disabled] 0.0% (0/1), failed.
error: bundling failed: ambiguous resolution: module `/Users/so/Documents/workspace/my-app/index.android.js` tries to require `react-native`, but there are several files providing this module. You can delete or fix them:
* `/Users/so/Documents/workspace/my-app/node_modules/react-native-svg/node_modules/react-native/package.json`
* `/Users/so/Documents/workspace/my-app/node_modules/react-native/package.json`
Versions:
react-native-cli: 1.0.0
react-native: 0.48.4
react-native-svg: 6.0.0-rc1
Any idea?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 21
- Comments: 25
Try
yarn start --reset-cache
Just a small correction: to pass
--reset-cache
viayarn
, you need to pass the a separator first, otherwisenode
will be called without the argument.@RuiDamiao ,restart your mac will resolve this problem.Works for me.
I fixed it by adding below lines to the pod file, to make sure CocoaPod gets React dependency from node_modules instead of creating a new directory and pulling from other repo.
@perzect I’ve already tried. The problem is that this path ‘D:\PORTAL.MOBILE\PortalMobile\node_modules\react-native-view-more-text\node_modules\react-native\package.json’ doesn’t exist. I don’t know what to do. I cloned the project again and the first time worked well, I’ve installed another module and I got this error again and now even when I clone the project (again) I get this error right away…
UPDATE If anybody has a similiar problem i solved my with this
@endel That’s no longer necessary in the latest version of yarn.
I fixed this by removing all Pod stuff and reinstall them
I had the same problem. Any solution did not help but cloning project in new folder solve this.
there are two different versions of react-native in your package.json files.
I’ve restarted my Mac, and I have tried with
yarn start -- --reset-cache
. Any other idea? This hapened when I added Podfile and started using Pods.@allanjsx 's solution worked for me, except I also had to delete the existing React pod in the ios dir.
Strange that React Native will let this problem occur by default. Lots of packages end up creating a duplicate React pod if you don’t force it to use the one from
node_modules
; I encountered it with thereact-native-camera
package.@RuiDamiao Yep! Delete node_modules will not resolve this Pro. Maybe the key is 'npm uninstall '.I’ll try this next time.
I had to delete the node_module and Pods folder. and
npm i
and thenpod update
pod install
.This is because initially I started the project and in the podfile there was no React mentioned. It was working, then I added another library ( fast-image) and that needed the React to be inside the podfile and then after that it got confused.
Similar to @xe4me solution, this worked for me:
Most likely you have react native being provided as a variable from the ios pods/React/package.json file, as well as from the base package.json file. Please confirm if this is the case.