克隆并运行从GitHub反应本机项目

Saa*_*ran 14 reactjs react-router react-native

我正在尝试在手机中构建并运行本机应用程序.我尝试使用"入门"并且工作正常.我执行以下操作

  1. cd AwesomeProject
  2. react-native start
  3. 在终端中打开一个新选项卡
  4. curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

  5. react-native run-android

它在我的Android手机中运行.

现在我正在尝试从GitHub运行一个项目,我做了以下操作

  1. git clone https://github.com/h87kg/NavigatorDemo.git
  2. cd NavigatorDemo
  3. react-native start

我收到Command 'start' unrecognized. Did you mean to run this inside a react-native project?错误.我该怎么做才能运行这个项目?任何帮助表示赞赏.提前致谢.

更新

安装依赖项后,npm install我可以运行服务器.现在,当我尝试运行时,react-native run-android我收到以下错误

JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Could not install the app on the device, see the error above.
Run Code Online (Sandbox Code Playgroud)

Pir*_*hah 9

您是否安装了节点模块?尝试npm install

  1. git clone https://github.com/h87kg/NavigatorDemo.git
  2. cd NavigatorDemo
  3. npm install
  4. react-native start


Bad*_*eeq 8

解决方案感觉就像一个黑客..问题是android文件夹中的gradlew文件不再可执行,因为你从git repo克隆它.

基本上,当你这样做时react-native run-android,它会做很多包括为你运行命令的事情cd android && ./gradlew installDebug.就在那里,它试图执行gradlew,但不能,导致文件不可执行.这就是你得到那个错误的原因.

cd进入android文件夹,并做chmod +x gradlew.这应该修复它,而不是复制文件..