pranay godha
pranay godha

Reputation: 655

Unable to resolve module 'AccessibilityInfo', when trying to create release bundle

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.

Upvotes: 42

Views: 46370

Answers (18)

jljonnard
jljonnard

Reputation: 9

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.

Upvotes: 0

Asma_Kh
Asma_Kh

Reputation: 93

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

Upvotes: 0

Christian Hujer
Christian Hujer

Reputation: 17955

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

Upvotes: 2

Jamie Birch
Jamie Birch

Reputation: 6112

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.

Upvotes: 0

Trent W
Trent W

Reputation: 95

@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 [email protected]
react-native run-android
npm install --save [email protected] [email protected]
npm uninstall --save babel-preset-react-native
npm install --save [email protected]
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"]
}

Upvotes: 0

Khurshid Ansari
Khurshid Ansari

Reputation: 5095

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.

Upvotes: 5

SirPhemmiey
SirPhemmiey

Reputation: 641

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"

Upvotes: 1

Vaibhav KB
Vaibhav KB

Reputation: 1745

Issue fixed - Working 100% !

npm remove --save react-native
npm install --save [email protected]
npm remove babel-preset-react-native
npm install --save [email protected]

Upvotes: 0

Abhishek Garg
Abhishek Garg

Reputation: 3242

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 

Upvotes: 0

Kamlesh Acharya
Kamlesh Acharya

Reputation: 17

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.

Upvotes: 0

tunde
tunde

Reputation: 1

Try the following:

npm remove --save react-native
npm i --save [email protected]
npm remove babel-preset-react-native
npm i --save [email protected]

Upvotes: 0

Chamal
Chamal

Reputation: 59

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

it will fix your problem!

Upvotes: 3

Umesh Patadiya
Umesh Patadiya

Reputation: 740

    "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

Upvotes: 6

mr L
mr L

Reputation: 1018

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 [email protected]
react-native run-android
npm install --save babel-core@latest babel-loader@latest
npm uninstall --save babel-preset-react-native
npm install --save [email protected]
react-native run-android

Upvotes: 71

JFC
JFC

Reputation: 327

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 [email protected]

If you want to know the reason follow this issue.

Upvotes: 17

Raikumar Khangembam
Raikumar Khangembam

Reputation: 1008

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 [email protected]

again intsalled

npm install -g [email protected]

then this installation of creating react-native project work out

react-native init --version="0.55.4" myprojectname

Upvotes: 8

Saaksshi Tyagi
Saaksshi Tyagi

Reputation: 11

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.

Upvotes: 0

Ashok R
Ashok R

Reputation: 20786

npm cache clean --force worked for me

Upvotes: 0

Related Questions