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?
Try yarn start --reset-cache
Yep, that works. Thanks!
Just a small correction: to pass --reset-cache via yarn, you need to pass the a separator first, otherwise node will be called without the argument.
yarn start -- --reset-cache
...
node node_modules/react-native/local-cli/cli.js start --reset-cache
@endel That's no longer necessary in the latest version of yarn.
I´m getting a similar error:
Bundling index.js [development, non-minified] 0.0% (0/1), failed.
error: bundling failed: ambiguous resolution: module D:\PORTAL.MOBILE\PortalMobile\index.js tries to require react-native, but there are several files providing this module. You can delete or fix them:
D:\PORTAL.MOBILE\PortalMobile\node_modules\react-native-view-more-text\node_modules\react-native\package.jsonD:\PORTAL.MOBILE\PortalMobile\node_modules\react-native\package.json
I've already tried this comands: 'yarn start --reset-cache' 'node node_modules/react-native/local-cli/cli.js start --reset-cache' 'rm -rf node_modules && npm install'
Any idea?
@RuiDamiao ,restart your mac will resolve this problem.Works for me.
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.
@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
- npm uninstall {module name}
- rmdir /s /q node_modules -npm install -npm start -- --reset-cache (the error disappeared and the module was missing)
- npm install {module name} (everything is fine now)
@RuiDamiao Yep! Delete node_modules will not resolve this Pro. Maybe the key is 'npm uninstall '.I'll try this next time.
I had the same problem. Any solution did not help but cloning project in new folder solve this.
if these doesn't work yarn start -- --reset-cache check manually if there is another node_module inside the project.I had the same issue bcoz I duplicated the same project inside the project. delete the node_module if a duplicate exists.
I fixed this by removing all Pod stuff and reinstall them
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.
pod 'React', :path => '../node_modules/react-native'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
@allanjsx Its throwing algorithm' file not found
@PavanGangireddy you can find the issue (currently opened) for the algorithm error here, in one of the solution/comments I found this gist to fix many issues coming from cocoapods
I had to delete the node_module and Pods folder. and npm i and then pod 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.
@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 the react-native-camera package.
@allanjsx 's solution worked
there are two different versions of react-native in your package.json files.
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.