New React Native project with old version of react native

IosXcodeReactjsReact Native

Ios Problem Overview


I am trying to create a new react native project which should utilize an older version of react-native.

The result I would like would be to do something like: react-native init MyProject but have the version of react-native it uses be 0.13.2.

However, there doesn't seem to be any options with react-native-cli for initializing with old versions of react-native.

Performing react-native init MyProject and then dowgrading react-native in package.json also does not work because the init command installs a bunch of xcode templates which are used to build the app and there is no dowgrade command which will dowgrade these templates. (There is an upgrade command.)

I tried downgrading my version of react-native-cli to 0.1.4 which was current when react-native 0.13 was current, but this did not work. From looking at the cli source, it seems it always initializes with just the newest version of react-native.

I realize this is pretty weird to want to start a new project at an old version, but I have a weird set of requirements that are forcing this.

Ios Solutions


Solution 1 - Ios

There is a new parameter in react-native init that allows just this. Try:

react-native init --version="[email protected]" MyNewApp

Here my source. I have successfully tested it with react-native-cli 2.0.1.

Solution 2 - Ios

rninit is a replacement for react-native init that allows you to specify a particular version of react-native to use.

Install rninit globally:

npm install -g rninit

Specify which version of react-native to use:

rninit init [Project Name] --source react-native@0.14.2

Thanks to @vanson-wing-leung for pointing me to rninit

Solution 3 - Ios

Use the --version flag.

react-native init blank --version react-native@0.14.2

Solution 4 - Ios

Try this:

If you install the version of react-native that you want in your project, you can then navigate to (project)/node_modules/react-native/local-cli. Here you will see three generator folders which enclose the exact files RN would have used to initiate a project.

It's a bit manual, but at least you'll have access to the original files.

Solution 5 - Ios

specify react-native version at the time of installing

something like this

react-native init --version="[email protected]" ExampleApp

Solution 6 - Ios

The only solution that works with react native latest cli is

react-native init NewProject --version X.XX.X 

e.g

react-native init NewProject --version 0.61.5 

Thanks @Shamendra

Solution 7 - Ios

Here's the command as of April 2022.

npx react-native init newproject --version="0.66.4"

Solution 8 - Ios

react-native init MyApp --version [email protected]

Solution 9 - Ios

For existing react native project to downgrade run

npm install react-native@0.13.2

Then verify the version by running

react-native -version

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJordan EllView Question on Stackoverflow
Solution 1 - IosmartinarroyoView Answer on Stackoverflow
Solution 2 - IosemmbyView Answer on Stackoverflow
Solution 3 - IosBenjamin J. BenoudisView Answer on Stackoverflow
Solution 4 - IosJohn ShammasView Answer on Stackoverflow
Solution 5 - Iosomkar yadavView Answer on Stackoverflow
Solution 6 - IosSumantaView Answer on Stackoverflow
Solution 7 - IosprojectdsView Answer on Stackoverflow
Solution 8 - IosAshutosh DashView Answer on Stackoverflow
Solution 9 - IoshzakView Answer on Stackoverflow