bundling error on react native app (ambigous resolution)

Viewed 2631
Bundling `index.js`  [development, non-minified]  0.0% (0/1), failed.
error: bundling failed: ambiguous resolution: module `C:\Users\mtlok\Desktop\RN2\pep_beta\index.js` tries to require `react-native`, but there are several files providing this module. You can delete or fix them:

  * `C:\Users\mtlok\Desktop\RN2\pep_beta\node_modules\react-native-responsive-dimensions\node_modules\react-native\package.json`
  * `C:\Users\mtlok\Desktop\RN2\pep_beta\node_modules\react-native\package.json`

Im getting this error when bundling react-native app.

This issue may be caused by the react-native-responsive-dimensions package

Here is the package.json file:

{
  "name": "react-native-responsive-dimensions",
  "version": "1.0.1",
  "description": "Resposive fontSize, height and width for your react-native components.",
  "main": "src/index.js",
  "scripts": {
    "start": "node src/index.js",
    "test": "exit 0"
  },
  "keywords": [
    "react-native",
    "responsive",
    "responsive-height",
    "responsive-width",
    "responsive-font-size",
    "fontSize",
    "responsive-dimensions"
  ],
  "author": "DaniAkash <s.daniakash@gmail.com> (https://github.com/DaniAkash)",
  "repository": "DaniAkash/react-native-responsive-dimensions",
  "license": "MIT",
  "dependencies": {
    "react-native": "x"
  }
}

Also, there is a node_modules folder located inside node_modules/react-native-responsive-dimensions.

Is there a quick fix?

2 Answers

Try this command. maybe it's because of cache.

yarn start -- --reset-cache

or

npm start -- --reset-cache

if it doesn't work you can try react-native-git-upgrade or you can just delete node_modules folder then run npm install,react-native upgrade ande react-native-link

You can uninstall react-native-responsive-dimensions package first.

npm uninstall react-native-responsive-dimensions --save

And then

yarn start -- --reset-cache or npm start -- --reset-cache
react-native run-android or react-native run-ios
Related