5

When I try to run my React Native app on the iOS simulator, I'm presented with a red screen with the following error:

Ambiguous resolution: module '/Users/my-user/Documents/my-RN-app/app/index.js' tries to require 'react-native-vector-icons', but there are several files providing this module. You can delete or fix them:

/Users/my-user/Documents/my-RN-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app/my-RN-app/node_modules/react-native/local-cli/core/__fixtures__/files/package.json

/Users/my-user/Documents/my-RN-app/node_modules/react-native/local-cli/core/__fixtures__/files/package.json

However, both of those above files (the package.json files) are missing. I had actually gotten this error before, so I decided to delete the package.json file in the first directory location mentioned above (under ios/build/.. etc.) and refreshed the app and it loaded just fine. Now, after trying to start up my app again in the iOS simulator, I am back to the same error, but I cannot delete the package.json file because it doesn't even exist now in either location.

I've tried to just comment out the import of the react-native-vector-icons lib in my app/index.js file and restarting the sim, but the error still appears.

So finally, I've tried this:

  1. sudo rm -rf node_modules (I get "permission denied" if I don't use sudo although it appears I have full read/write permission on all the files/folders in this project)
  2. sudo rm -rf ios/build
  3. npm install
  4. cd ios && pod install
  5. react-native link

And then back into Xcdoe: Product > Clean, after which I ran the simulator again. Still the same error.

As requested, here is my package.json file:

 {
  "name": "myApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "run-ios": "node_modules/.bin/react-native run-ios",
  },
  "dependencies": {
    "art": "^0.10.1",
    "auto-bind": "^1.1.0",
    "axios": "^0.16.1",
    "eslint-plugin-react-native": "^2.3.1",
    "jwt-decode": "^2.2.0",
    "moment": "^2.19.1",
    "native-base": "^2.3.1",
    "prop-types": "^15.5.8",
    "pubnub": "^4.18.0",
    "react": "^16.0.0",
    "react-native": "^0.49.3",
    "react-native-actionsheet": "^2.3.0",
    "react-native-device-info": "^0.11.0",
    "react-native-fabric": "^0.5.1",
    "react-native-fingerprint-scanner": "^2.2.1",
    "react-native-flip-card": "^3.5.2",
    "react-native-google-analytics-bridge": "^5.3.3",
    "react-native-haptic": "^1.0.5",
    "react-native-image-base64": "^0.1.3",
    "react-native-image-picker": "^0.26.7",
    "react-native-image-resizer": "^1.0.0",
    "react-native-keyboard-aware-scroll-view": "^0.4.3",
    "react-native-keyboard-spacer": "^0.4.1",
    "react-native-keychain": "^1.2.1",
    "react-native-maps": "^0.17.1",
    "react-native-modal-dropdown": "^0.5.0",
    "react-native-mplayer": "^1.0.1",
    "react-native-notifications-badge-extensions": "^1.0.5",
    "react-native-permissions": "^0.2.7",
    "react-native-pie": "^0.4.0",
    "react-native-router-flux": "^4.0.0-beta.26",
    "react-native-snap-carousel": "^3.2.3",
    "react-native-tag-input": "0.0.18",
    "react-native-tooltip": "^5.2.0",
    "react-native-uuid-generator": "^3.0.2",
    "react-native-vector-icons": "^4.3.0",
    "react-native-version-number": "^0.1.3",
    "react-native-voice": "^0.2.5",
    "react-navigation": "^1.2.0",
    "sprintf-js": "^1.0.3",
    "validator": "^9.2.0"
  },
  "devDependencies": {
    "babel-jest": "18.0.0",
    "babel-preset-react-native": "^4.0.0",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "enzyme-to-json": "^3.3.1",
    "eslint": "^3.14.1",
    "eslint-config-airbnb": "^14.1.0",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "^4.0.0",
    "eslint-plugin-react": "^7.5.1",
    "jest": "18.1.0",
    "jest-serializer-enzyme": "^1.0.0",
    "jsdom": "11.6.2",
    "jsdom-global": "3.0.2",
    "metro-bundler": "^0.20.0",
    "react-addons-test-utils": "^15.6.2",
    "react-dom": "^16.2.0",
    "react-native-mock": "^0.3.1",
    "react-test-renderer": "16.0.0-alpha.12",
    "sinon": "^4.1.2"
  },
  "resolutions": {
    "moment": "2.19.1"
  }
}
Attila
  • 1,097
  • 2
  • 19
  • 45
  • 1
    Post your `package.json`. Also consider reading through [this issue](https://github.com/oblador/react-native-vector-icons/issues/626). In particular, check out [this comment](https://github.com/oblador/react-native-vector-icons/issues/626#issuecomment-357405396) as that issue might be related to what you're running into. – Michael Cheng Mar 28 '18 at 21:45
  • 1
    Try `npm start -- --reset-cache` – Mukesh Soni Mar 29 '18 at 02:42
  • Michael: I've posted my `package.json` above, but the comment you linked to may have helped (it didn't solve the issue, but I deleted the file it suggested anyway, and then ran the commands below, and now I'm good). Mukesh: I tried running that command and it seemed to have done the trick. Here's what I ran, in order: `rm -rf ios/build` `pod install` `react-native link` and then finally `npm start -- --reset-cache` and then I started up the sim and no errors, yay! – Attila Mar 29 '18 at 14:03
  • Nvm, spoke too soon. The app started, and then I tried to start the remote debugger as well, and now I'm getting a similar error, except now with `tries to require react-native` instead of `react-native-vector-icons`. I opened up xcode and did Product > Clean and tried to launch the app through xcode (instead of with the react native cli) and now it's working... I'm so confused on what the root problem actually is. – Attila Mar 29 '18 at 14:38
  • I ran into a similar problem, this might help? https://stackoverflow.com/questions/52737251/how-do-i-prevent-react-native-device-info-causing-react-ambiguity-on-my-setup/52776146#52776146 – deworde Oct 12 '18 at 09:14

1 Answers1

1

I had to manually link the React pod to node_modules:

pod 'React', :path => '../node_modules/react-native'

Then clean and build again

Chris Feist
  • 1,678
  • 15
  • 17