react-native-svg icon indicating copy to clipboard operation
react-native-svg copied to clipboard

Ambiguous resolution

Open oertels opened this issue 9 years ago • 25 comments

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?

oertels avatar Sep 28 '17 08:09 oertels

Try yarn start --reset-cache

vlad-zhukov avatar Oct 09 '17 11:10 vlad-zhukov

Yep, that works. Thanks!

oertels avatar Oct 09 '17 13:10 oertels

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 avatar Oct 31 '17 17:10 endel

@endel That's no longer necessary in the latest version of yarn.

jcurtis avatar Oct 31 '17 20:10 jcurtis

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.json
  • D:\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 avatar Nov 10 '17 17:11 RuiDamiao

@RuiDamiao ,restart your mac will resolve this problem.Works for me.

perzect avatar Nov 13 '17 09:11 perzect

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.

nonameolsson avatar Nov 13 '17 17:11 nonameolsson

@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 avatar Nov 14 '17 14:11 RuiDamiao

@RuiDamiao Yep! Delete node_modules will not resolve this Pro. Maybe the key is 'npm uninstall '.I'll try this next time.

perzect avatar Nov 16 '17 09:11 perzect

I had the same problem. Any solution did not help but cloning project in new folder solve this.

vladdnepr1991 avatar Nov 16 '17 15:11 vladdnepr1991

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.

kaderhussain avatar Feb 23 '18 05:02 kaderhussain

I fixed this by removing all Pod stuff and reinstall them

futurechallenger avatar Mar 18 '18 02:03 futurechallenger

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 avatar May 10 '18 18:05 allanjsx

@allanjsx Its throwing algorithm' file not found

PavanGangireddy avatar May 17 '18 04:05 PavanGangireddy

@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

rgkobashi avatar May 18 '18 06:05 rgkobashi

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.

xe4me avatar Jun 04 '18 06:06 xe4me

@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.

aleczadikian avatar Jul 08 '18 20:07 aleczadikian

@allanjsx 's solution worked

Uzairrrr avatar Sep 12 '18 12:09 Uzairrrr

there are two different versions of react-native in your package.json files.

shoorkaii avatar Sep 22 '18 09:09 shoorkaii

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.

Kielan avatar Oct 16 '18 23:10 Kielan