React Native version check - react-native

I wanted to check the version of the react native I was using in my project when I used the command from my root folder :
D:\Reactnative\Albums>npm view react-native version
0.56.0
The version was 0.56.0 which is not the version I have installed, but on:
D:\Reactnative\Albums>react-native -v
react-native-cli: 2.0.1
react-native: 0.55.4
The version mentioned here is 0.55.4, which is correct.
So why this conflict?

npm view react-native version
You can check the latest version of react native. You can run it under the root of your project or everywhere. Of course, you will need internet connection to check latest version.
react-native -v
If you run under the root of project, it will return the version of two npm packages, react-native-cli and react-native. Those versions are using in your project.

Just wanted to clarify Aung's answer:
npm view react-native version checks globally while react-native -v ran inside project's root folder checks version of the app itself.

Macbook M1 Chip
npm view react-native version

Related

In, react-native info how to check RN version?

In Terminal,
react-native: 0.68.0 => 0.60.0
does it mean that this project version is 68 or 60? In pacakge.json, i manually changed it to 0.68 and then npm install. and I checked react-native info.
Don't try to change manually react native version because sometimes as per version level some internal files or set up not done properly and it will create issue for running project Use below command for upgrade project
npx react-native upgrade
If you want to upgrade specific version then use below command
npx react-native upgrade 0.68
after then check react native version It will show 0.68

Strange react-native Version Number When Running from Local `node_modules`

When I run react-native --version from the global installation, it reports to me what I consider to be an accurate version number, like this:
react-native-cli: 2.0.1
react-native: 0.61.4
However, when I run yarn react-native --version (from the local installation at node_modules, it reports the version number simply as 3.2.1.
Can anyone explain why?
EDIT: The definitive way to find the react native version number for your local project is to run react-native info locally. This can be done one of the following ways:
npm run react-native info
yarn react-native info
In answer to the original question: "Why am I seeing the strange version number?", here is my analysis:
As it turns out, I did not have react-native installed globally. I had react-native-cli installed globally.
If you open Terminal and cd to some random directory and run react-native --version (assuming you also have react-native-cli installed), the response will look something like this:
$ react-native --version
react-native-cli: 2.0.1
react-native: n/a - not inside a React Native project directory
If you then cd to a react-native project's root folder and run react-native --version, it will return the actual version number of that local project.
However, when you run yarn react-native --version from the root folder of a react-native project, what actually gets returned is the version of the #react-native-community/cli installation. (You get the same result if you run npx react-native --version or if you look in the package.json file of the local #react-native-community/cli installation in node_modules/#react-native-community/cli.
So, long story short, if you want to know the exact react-native version your local project is using, use react-native info (easy) or open up ./node_modules/react-native/package.json and it will tell you the version number.

New react-native-app with react-native 0.59.9 or lower

What is the best/easiest way to create new react-native-app using react-native-0.59.9 or lower?
Trying to use https://github.com/futurepress/epubjs-rn , which only runs in react-native 0.59 or lower.
The example app in https://github.com/futurepress/epubjs-rn/EpubReader does not work out of the box.
please use epubjs-rn-62
usage
To use the components in your own app install via npm or yarn
npm install --save epubjs-rn
import { Epub } from 'epubjs-rn';
Then you can add the reader element in your code:
<Epub src={"https://s3.amazonaws.com/epubjs/books/moby-dick/OPS/package.opf"}
flow={"paginated"} />
In order to start a new project with a specific React Native version, you can use the --version
react-native init ProjectName --version="0.59.9"
Check official documentation for more information.
EDIT
But in order to run an older version, you need to downgrade your React Native CLI version according to Compatibility of React Native CLI.
If you have already installed a version of react-native CLI, uninstall it using
npm uninstall -g react-native-cli
Then you have to install an older version as below,
npm install react-native-cli#1.0.0
Hope this will help you.

How to run an old version of react native

Just a quick question, how to run an existing older version of react native project. Lets say version 0.59.10 , without upgrading it. what would be the command line commands. Thanks
You should navigate to project directory (if you aren't yet)
cd PATH_TO_PROJECT_DIRECTORY
run the following command to install the dependencies
npm install
then if the react-native version is 0.59.10 and lowers you should also run the command below to link the dependencies to your native android and ios project.
react-native link
and then run one the following commands based on your device
for android
react-native run-android
for ios
react-native run-ios

How to downgrade react-native from 0.56.0 to 0.55.4 version?

Actually I am using react-native-camera in my app but it is not working in this version (react-native: 0.56.0) & its working in this version(react-native: 0.55.4).
So now I want to downgrade the react-native: 0.56.0 to react-native: 0.55.4.
My System configuration:
npm 6.1.0,
react-native-cli: 2.0.1,
react-native: 0.56.0,
Mac OS, Xcode 9.3
Thank you
So open the file of your project named as package.json
Inside it you can find react-native": "0.56.4" replace this version with react-native": "0.55.4" or whatever the version you want
Then save the file
Go to the terminal or power sell
Rich to your project directory and run the command npm install
After installation check the version of react-native by running the command react-native --version and make sure that version is which you changed in package.json
Restart your project and you are ready to go
Open the file of your project named as package.json
Inside it you will find react-native": "0.56.0" replace this version with react-native": "0.55.4" or the version which you want to change and save the file
go to the terminal or power sell
Go to your project directory and run command npm install
after installation check the version of react-native by running the command react-native -v and check that the version which you changed in package.json is same as the version you get here, then restart your project.