0
votes

https://facebook.github.io/react-native/docs/getting-started.html

I have followed the instruction that are on this link. But app is not starting on emulator enter image description here

  1. I then follow the instructions on Delete the node_modules folder - rm -rf node_modules && npm install
  2. Reset packager cache - rm -fr $TMPDIR/react-* or node_modules/react-native/packager/packager.sh --reset-cache
  3. Clear watchman watches - watchman watch-del-all Recreate the project from scratch

and also create whole new project again to but every time this error pops-up

I have

  • npm 4.6.1

  • node v8.11.4

  • jdk version 8
{
  "name": "p3",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.4.1",
    "react-native": "0.56.0"
  },
  "devDependencies": {
    "babel-jest": "23.4.2",
    "babel-preset-react-native": "5",
    "jest": "23.5.0",
    "react-test-renderer": "16.4.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

Any help please.

3
React and React-Native versions?HedeH
@HedeH edited my post with version specified.Rajan Lagah

3 Answers

2
votes

It has been observed that, latest react native version is having a bug in dependencies. I have found it working by modifying the package.json file. Please upadate your package.json file by adding below code:

"dependencies": {
    "react": "^16.4.1",
    "react-native": "^0.55.4"
 },
 "devDependencies": {
    "babel-preset-react-native": "^4.0.0",
 },

and then use below commands:

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

Try creating the project using stable versions, do react-native init <Project Name> --version="0.55.2". After this try react-native run-android.

1
votes

If you want to keep using the react-native 0.56.0 version,

Try this configuration in package.json:

"dependencies": {
  ...
  "babel-runtime": "^6.26.0",
  "react": "^16.4.2",
  "react-native": "^0.56.0",
  ...
},
"devDependencies": {
  ...
  "@babel/core": "^7.0.0-beta.56",
  "babel-eslint": "^8.2.3",
  "babel-jest": "^22.1.0",
  "babel-preset-react-native": "^5.0.0",
  ...
},

If that doesn't work, also try running this script:

Add a script to the scripts section in the package.json file under the root project dir and call it build:android: (The name doesn't matter)

{
  ... 
  "scripts": {
    ...
    "build:android": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
    ...
  },
  ...
}

Run it from the terminal like this:

npm run build:android

Hope it helps :)