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
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
{ "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.
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
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 :)
Try creating the project using stable versions, do react-native init <Project Name> --version="0.55.2"
. After this try react-native run-android
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.