39

I am running

react-native bundle --platform windows --dev false --entry-file index.windows.js --bundle-output windows/app/ReactAssets/index.windows.bundle --assets-dest windows/app/ ReactAssets/

command to create release bundle, but I am getting following error

Unable to resolve module `AccessibilityInfo` from `C:\Users\godha.pranay\project\node_modules\react-native\Libraries\react-native\react-native-implementation.js`: Module does not exist in the module map



This might be related to https://github.com/facebook/react-native/issues/4968

To resolve try the following:

  1. Clear watchman watches: `watchman watch-del-all`.

  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.

  3. Reset Metro Bundler cache: `rm -rf $TMPDIR/react-*` or `npm start -- --reset-cache`.  4. Remove haste cache: `rm -rf $TMPDIR/haste-map-react-native-packager-*`.

I tried everything recommended on internet, nothing is working. I am totally stuck on it. Please help.

pranay godha
  • 625
  • 2
  • 7
  • 13
  • I also encountered the same problem. After checking some materials, I found that this problem should be a bug of version 0.56. – westinyang Aug 02 '18 at 07:05

18 Answers18

70

It seems like a bug in 0.56 related to dependencies. The "solution" is to find the correct combination of dependencies' versions. We found a workaround by installing those versions EXACTLY:

react-native >> 0.55.4
babel-core >> latest 
babel-loader >> latest
babel-preset-react-native >> 4.0.0

So you have to run those commands in order:

react-native init AwesomeProject
cd AwesomeProject
react-native run-android
npm uninstall react-native
npm install --save react-native@0.55.4
react-native run-android
npm install --save babel-core@latest babel-loader@latest
npm uninstall --save babel-preset-react-native
npm install --save babel-preset-react-native@4.0.0
react-native run-android
mr L
  • 1,008
  • 13
  • 20
  • Do i need to do this every time i create a new project? – Pravinsingh Waghela Jul 30 '18 at 15:27
  • @PravinsinghWaghela Apparently, you need this if you started a project with the version 0.56. Otherwise, working with previous versions like 0.55.4 does not cause any issues. – mr L Jul 30 '18 at 17:00
  • @MujtabaZaidi They corrected the bug in the last version of react native, I highly recommend you to move to the last version. – mr L Mar 14 '19 at 08:54
  • I am having react-native 0.63.4, and getting error Unable to resolve module `AccessibilityInfo` from `react-native-calendars/node_modules/react-native/Libraries/react-native/react-native-implementation.js`: AccessibilityInfo could not be found within the project. – Narendra Singh Jan 11 '21 at 14:23
  • @ZeeshanAhmadKhalil Yes, I just updated the react native version of that custom library -- `react-native-calendars`, and that worked for me :) – Narendra Singh Apr 25 '22 at 11:02
  • @NarendraSingh for me it worked by uninstalling `node_modules` & `package-lock.json`. Then `npm install` – Zeeshan Ahmad Khalil Apr 25 '22 at 17:39
  • I got this error before and it was resolved by reinstalling `node_modules`; now it's not working. Also updated `react-native-calendars` and `@babel/core` to latest versions but still same error. – Zeeshan Ahmad Khalil Aug 03 '23 at 10:41
17

If you are running the reactive-native version 0.56.0 then downgrade it to 0.55.4.

cd "on your project directory"
npm install react-native@0.55.4

If you want to know the reason follow this issue.

David Noreña
  • 3,951
  • 1
  • 28
  • 43
JFC
  • 328
  • 4
  • 15
8

i had the same issue.

previous my react-native version was

C:\WINDOWS\system32>react-native -v
react-native-cli: 2.0.1
react-native: 0.56.0

then i uninstall react-native

C:\WINDOWS\system32>npm uninstall -g react-native-cli
removed 41 packages in 3.999s

then i installed react-native

npm install react-native@0.55.4

again intsalled

npm install -g react-native-cli@1.2.0

then this installation of creating react-native project work out

react-native init --version="0.55.4" myprojectname
Raikumar Khangembam
  • 948
  • 1
  • 12
  • 24
  • Installing react-native before init of the project caused permission issues for me. Specifying the version at init time, alone, did the trick. – Atomox Aug 19 '18 at 17:36
6
    "dependencies": {
        "react": "^16.4.1",
        "react-native": "^0.55.4"
      },
    "devDependencies": {
        "babel-preset-react-native": "^4.0.0",
      },

then hit following commands

    npm update
    npm cache clean --force
    cd android
    gradlew clean
    cd..
    react-native run-android

Worked for me

Umesh Patadiya
  • 710
  • 10
  • 33
5

I also found bug in latest of react-native 0.56.0. I tried to downgrade the but still not working for me. This problem in windows operating system not in mac.

Simple I tried:

react-native init ProjectName --version=0.55.4

It is working fine.

Khurshid Ansari
  • 4,638
  • 2
  • 33
  • 52
3

react-native 0.56.0 is broken in Windows platform. please use 0.55.4

it will fix your problem!

Chamal
  • 57
  • 1
  • 4
  • If the OP is asking for a specific version of react-native, it is generally better to help the OP make their set up work instead of recommending a different version. – Nerdi.org Jul 26 '18 at 19:38
  • 1
    @Nerdi.org then go and do the same comment for all the answers :) because mostly they said the same – badr aldeen Jul 28 '18 at 06:35
  • Your answer popped up in the official SO review queue. We're encouraged to leave helpful comments / votes, or flag if a moderator is needed. I didn't think a moderator was needed, so I replied instead. – Nerdi.org Aug 06 '18 at 18:38
2

The following fixes the issue:

npm install babel-preset-react-native

A similar issue can arise when trying to run npm run flow. The fix for that is

npm install babel-preset-flow
Christian Hujer
  • 17,035
  • 5
  • 40
  • 47
1

There's a bug in the recent version of react-native. To fix (at least temporarily) the problem use the following version of react and react native.

"react": "^16.4.1",
 "react-native": "^0.55.4"
SirPhemmiey
  • 585
  • 6
  • 7
0

npm cache clean --force worked for me

Ashok R
  • 19,892
  • 8
  • 68
  • 68
0

It doesn't work on npm cache clean --force or restart system or deleting node module and reinstall. When we create fresh project with latest version it seems top work fine but on upgrading everything seems to stop working

I suggest to start new project.

0

Try the following:

npm remove --save react-native
npm i --save react-native@0.55.4
npm remove babel-preset-react-native
npm i --save babel-preset-react-native@2.1.0
ivcubr
  • 1,988
  • 9
  • 20
  • 28
tunde
  • 1
  • 1
0

Perfect Solution

Try to make the version compatible to each other for best way

here is the link

and keep everything up to date such as android sdkVersio such as 27 or 28.

Quoc Nguyen
  • 2,839
  • 6
  • 23
  • 28
0

React native + native base + redux + react -compatible versions till date . working flawlessly on linux as well as Windows.

package.json

{
  "name": "ExampleAPP",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "eslint": "^5.2.0",
    "native-base": "2.6.1",
    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-native-router-flux": "^4.0.1",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0"
  },

  }
}

if you still get error , remove node_modules folder and run commmand in terminal in your project directory

npm install 
Abhishek Garg
  • 3,092
  • 26
  • 30
0

Issue fixed - Working 100% !

npm remove --save react-native
npm install --save react-native@0.55.4
npm remove babel-preset-react-native
npm install --save babel-preset-react-native@2.1.0
Vaibhav KB
  • 1,695
  • 19
  • 17
0

@abinax's answer worked great for me.

I think instead of using latest for the babel packages, version numbers would be more appropriate due to future changes to babel potentially breaking existing compatibility.

Here are the version numbers that worked for me.

react-native >> 0.55.4
babel-core >> 6.26.3
babel-loader >> 8.0.4
babel-preset-react-native >> 4.0.0

And @abinax's answer with the version changes:

react-native init AwesomeProject
cd AwesomeProject
react-native run-android
npm uninstall react-native
npm install --save react-native@0.55.4
react-native run-android
npm install --save babel-core@6.26.3 babel-loader@8.0.4
npm uninstall --save babel-preset-react-native
npm install --save babel-preset-react-native@4.0.0
react-native run-android

You may also need to edit your .babelrc file if you're getting this error:

Couldn't find preset "module:metro-react-native-babel-preset" relative to directory  

Before .babelrc

{
  "presets": ["module:metro-react-native-babel-preset"]
}

After .babelrc

{
  "presets": ["react-native"]
}
Trent W
  • 95
  • 2
  • 9
0

Another approach: Uninstall your global copy of react-native-cli via one of these commands:

yarn global remove react-native-cli
npm uninstall -g react-native-cli

As far as I understand, your project may accidentally spawn the metro bundler from this globally-installed package rather than your own locally-installed one (I encountered this using the standard react-native-xcode.sh build script), and it becomes a problem when there are version mismatches. This is all that was needed to solve my problem for a fork of react-native v0.51 (when clearing caches and reinstalling every local node module had no effect).

I did also remove the following packages, which may not be relevant in practice: create-react-app, create-react-native-app, and react-native-macos-cli. Basically, just list all your globally installed packages and uninstall any React Native-related ones.

Jamie Birch
  • 5,839
  • 1
  • 46
  • 60
0

For me i had to replace the preset "react-native" in .babelrc by "module:react-native"

So .babelrc :

     {
     "presets": ["module:react-native"]
     }

and it will work fine

Asma_Kh
  • 93
  • 2
  • 15
0

I experienced the exact same issue on Android in RN 0.72.4 and deleting the cxx folder in Android/App has worked for me.

I advise you to also delete node_modules folder and build folder in Android/App to ensure it will build correctly.