ios 带有旧版本 React Native 的新 React Native 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34211131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
New React Native project with old version of react native
提问by Jordan Ell
I am trying to create a new react native project which should utilize an older version of react-native.
我正在尝试创建一个新的 React Native 项目,该项目应该使用旧版本的 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
.
我想要的结果是做类似的事情:react-native init MyProject
但是它使用的 react-native 版本是0.13.2
.
However, there doesn't seem to be any options with react-native-cli
for initializing with old versions of react-native.
但是,似乎没有任何选项可以react-native-cli
使用旧版本的 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.)
执行react-native init MyProject
然后降级 react-nativepackage.json
也不起作用,因为该init
命令安装了一堆用于构建应用程序的 xcode 模板,并且没有dowgrade
可以降级这些模板的命令。(有一个upgrade
命令。)
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.
我尝试将我的 react-native-cli 版本降级到0.1.4
当前 react-native0.13
是最新版本,但这不起作用。从查看 cli 源代码来看,它似乎总是只使用最新版本的 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.
我意识到想要在旧版本上开始一个新项目是很奇怪的,但是我有一组奇怪的要求迫使它这样做。
回答by martinarroyo
There is a new parameter in react-native init
that allows just this. Try:
有一个新参数react-native init
允许这样做。尝试:
react-native init --version="[email protected]" MyNewApp
Here my source. I have successfully tested it with react-native-cli
2.0.1.
这是我的来源。我已经成功地用react-native-cli
2.0.1测试了它。
回答by emmby
rninit
is a replacement for react-native init
that allows you to specify a particular version of react-native to use.
rninit
是替代react-native init
它允许您指定要使用的特定版本的 react-native。
Install rninit
globally:
rninit
全局安装:
npm install -g rninit
Specify which version of react-native to use:
指定使用哪个版本的 react-native:
rninit init [Project Name] --source [email protected]
Thanks to @vanson-wing-leung for pointing me to rninit
感谢@vanson-wing-leung 指点我 rninit
回答by Benjamin J. Benoudis
回答by omkar yadav
specify react-native version at the time of installing
在安装时指定 react-native 版本
something like this
像这样的东西
react-native init --version="[email protected]" ExampleApp
回答by John Shammas
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.
如果您react-native
在项目中安装了所需版本,则可以导航到(project)/node_modules/react-native/local-cli
. 在这里,您将看到三个generator
文件夹,其中包含 RN 用于启动项目的确切文件。
It's a bit manual, but at least you'll have access to the original files.
这有点手动,但至少您可以访问原始文件。
回答by Ashu
react-native init MyApp --version [email protected]
react-native init MyApp --version [email protected]
回答by hzak
For existing react native project to downgrade run
对于现有的反应本机项目降级运行
npm install [email protected]
Then verify the version by running
然后通过运行验证版本
react-native -version