React Native Version Mismatch Error - react-native

I am trying to run a react native application using the following command.
npm run android
I get the following error.
im using nvm - nvm use stable
Now using node v8.9.4 (npm v4.6.1)
**package.json**
{
"name": "client",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-native-scripts": "1.11.0",
"jest-expo": "23.0.0",
"react-test-renderer": "16.0.0"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js --watch"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"expo": "^23.0.4",
"react": "16.0.0",
"react-native": "0.50.3"
}
}
A different solution recommended rerunning the build process because there maybe some interference, but this did not work for me.

I managed to solve this my self. The error message was showing a react-native version of 0.50.3.
But the latest version is 0.52 as can be seen here https://facebook.github.io/react-native/versions.html.
So i updated package json to reflect this.
"dependencies": {
"react-native": "0.52"
}
then i deleted npm modules and reran npm install. This fixed my issue.
tldr; update package.json react-native dependency to reflect latest version.

I Had the same problem, and the KHAN give us the right solution.
I'm Putting here the package.json for thoses who need the fix:
{
"name": "project",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-native-scripts": "1.11.0",
"jest-expo": "25.0.0",
"react-test-renderer": "16.0.0"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js --watch"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"expo": "^25.0.0",
"react": "16.0.0",
"react-native": "0.52"
}
}

Related

yarn android not working with react native

i´m running my react native app with bare workflow, and when i try to execute it with yarn android i get this error:
Could not read script 'C:\Users\claud\OneDrive\├?rea de Trabalho\teste\node_modules\expo\scripts\autolinking.gradle' as it does not exist.
package.json
{
"name": "teste",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web"
},
"dependencies": {
"expo": "~47.0.9",
"expo-splash-screen": "~0.17.5",
"expo-status-bar": "~1.4.2",
"react": "18.1.0",
"react-native": "0.70.5"
},
"devDependencies": {
"#babel/core": "^7.12.9"
},
"private": true
}
In my case it was because of yarn's new policy, "PnP"!
There's a perfect workaround here

Getting Error: "React Native is not installed"

enter image description here
When I'm going to execute the command expo start, give me the following error, I'm starting to work with react native and I don't manage much, what can it be?
app.json
{
"expo": {
"name": "Project",
"slug": "Project",
"version": "1.0.0",
"orientation": "portrait",
"sdkVersion": "35.0.0",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
package.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"expo": "^35.0.0",
"react": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
"expo-status-bar": "^1.0.2",
"react-dom": "~16.11.0",
"react-native-web": "~0.11.7"
},
"devDependencies": {
"#babel/core": "^7.8.6",
"babel-preset-expo": "~8.1.0"
},
"private": true
}
new error
enter image description here
folders
I changed the files in the folder
\node_modules\metro-config\src\defaults\blacklist.js
in
var sharedBlacklist = [
/node_modules[/\\]react[/\\]dist[/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
for
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
now this error is showing up
this last error was solved by installing the expo directly on the emulator.
As it is shown in the error, React Native is not installed. So,
(1) npm install
(2) npm start
That's it. If you still get any problem, please update your question by containing your app.json file content.
UPDATE:
I think the problem is with your sdk version. Please try changing the version of the sdk version.
(1) replace your package.json with the following content. (Copy and Paste)
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"expo": "~37.0.3",
"expo-status-bar": "^1.0.2",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
"react-native-web": "~0.11.7"
},
"devDependencies": {
"#babel/core": "^7.8.6",
"babel-preset-expo": "~8.1.0"
},
"private": true
}
Above, I've changed the sdk version from 38 to 37.
(2) Delete node_module, and .expo folders if they have been created in your project root directory.
(3) npm install
(4) npm start
That's it. It should work now!
try changing the source of react-native in your package.json by changing this line:
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
for this
"react-native": "^0.63.0",

React native custom font not loaded

I'm new to react-native ,
i read a tutorial to import custom font in my project.
my font not working.
here is my project structure:
here is my package.json:
{
"name": "Arvandkala",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-native-scripts": "1.14.0",
"jest-expo": "~27.0.0",
"react-test-renderer": "16.3.1"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "jest"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"expo": "^27.0.1",
"react": "16.3.1",
"react-native": "~0.55.2"
},
"rnpm": {
"assets": [
"./assets/fonts"
]
}
}
also when i run react-native link i see this message on terminal:
Scanning folders for symlinks in /Users/hamed/Desktop/arvandkala/Arvandkala/node_modules (12ms)
rnpm-install info Linking assets to ios project
rnpm-install ERR! Something went wrong while linking. Error: Cannot read property 'pbxprojPath' of null
Please file an issue here: https://github.com/facebook/react-native/issues
Cannot read property 'pbxprojPath' of null
Run this command and try.
react-native upgrade

How to solve warnings from yarn

I did already solve:
warning " > react-native#0.54.3" has incorrect peer dependency "react#^16.3.0-alpha.1".
I just edit package.json dependencies:
...
"react": "^16.3.0-alpha.1",
...
and ran yarn.
But how can I solve following warnings:
warning "react-native > metro > #babel/plugin-check-constants#7.0.0-beta.38" has incorrect peer dependency "#babel/core#7.0.0-beta.38".
warning "jest-expo > babel-jest#22.4.3" has unmet peer dependency "babel-core#^6.0.0 || ^7.0.0-0".
my yarn version is 1.5.1
my whole package.json:
{
"name": "#######",
"version": "0.1.0",
"private": true,
"devDependencies": {
"jest-expo": "^25.1.0",
"react-native-scripts": "^1.11.1",
"react-test-renderer": "^16.2.0"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js --watch"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"#expo/vector-icons": "^6.3.1",
"exp": "^47.4.4",
"expo": "^23.0.4",
"react": "^16.3.0-alpha.1",
"react-native": "^0.54.3",
"react-navigation": "^1.5.8"
}
}

There is no QRCode on terminal when type npm start

I type command create-react-native-app <My package name>
then i type npm start i can see QRCode shows on my terminal
But when i type npm run eject for my project
I type npm start again. There's no QRCode show on my terminal any more.
I looking for some answer still can't fix it. It confused with me a lot.
Here is my environment:
Mac OS:10.13.4
{
"name": "TestMovie2",
"version": "0.1.0",
"private": true,
"devDependencies": {
"babel-preset-react-native-stage-0": "^1.0.1",
"eslint-config-rallycoding": "^3.2.0",
"jest": "^22.4.3",
"jest-react-native": "^18.0.0",
"react-test-renderer": "16.3.0-alpha.1"
},
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
"ios": "react-native run-ios",
"test": "jest"
},
"jest": {
"preset": "react-native"
},
"dependencies": {
"#shoutem/animation": "^0.12.2",
"#shoutem/ui": "^0.23.4",
"react": "16.3.0-alpha.1",
"react-native": "0.54.0"
}
}
Hope you have solved the problem , but anyone still facing the problem can just type expo start instead of npm start