设置通过react-native init命令创建的克隆的react-native项目

时间:2018-03-21 15:38:51

标签: react-native react-native-android react-native-ios

我使用react-native init创建了一个react-native项目XYZApp,该项目在GitHub仓库中推送。

现在,当我在另一个系统上克隆项目时。以下是目录结构

应用程序/ XYZApp

以下是我正在使用的一组命令和步骤。

cd app

brew install node

brew install watchman

npm install -g react-native-cli

install android studio and required SDKs

install X-Code

react-native init MyApp 

prompt: Directory MyApp already exists. Continue?:  (no) 

I am typing - yes

npm install [all dependencies]

react-native link

通过以上所有步骤,创建了一些新的默认文件,这些文件运行默认应用程序,对我能够运行应用程序的那些文件进行一些小的更改。但我知道这不是正确的做法。

我也尝试了其他几种方法, 比如npm start

我检查了几个链接,但在克隆后无法找到正确的设置方法。 其中大多数是create-react-native-app方法提到的。

如果有人可以帮我解决这个问题会很棒。

2 个答案:

答案 0 :(得分:1)

克隆后 不要这样做

react-native init MyApp 

prompt: Directory MyApp already exists. Continue?:  (no) 

I am typing - yes

npm install [all dependencies]

react-native link

只需转到克隆的应用程序目录XYZApp并执行

npm install

并设置为使用

运行应用程序
react-native run-android

答案 1 :(得分:0)

更新2019 React Native 0.60.0 +

首先,您需要通过运行来安装所有节点模块

npm install

如果您使用的是具有react-native-gesture-handler之类的本机依赖项的库,则需要正确链接这些库。为此,请运行

react-native link

要正确设置iOS项目,您需要安装CocoaPods依赖项:

cd ios && pod install
相关问题