如何修复“ReactNative:无法运行程序"错误 [英] How to fix 'ReactNative:Cannot run program' error

查看:180
本文介绍了如何修复“ReactNative:无法运行程序"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行命令时,我创建了一个全新的 React Native 项目:

I created a fresh new react native project, when i run the command:

react-native run-android 

我收到了这条消息:

yarn run v1.16.0

yarn run v1.16.0

$ react-native run-android

$ react-native run-android

信息 JS 服务器已经在运行.

info JS server already running.

信息正在安装应用程序...

info Installing the app...

启动 Gradle 守护进程,1 个不兼容的守护进程无法重用,使用 --status 了解详情

Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

*:ReactNative:Cannot run program "./node_modules/.bin/react-native" (在目录 "C:\Users\yelha\Desktop\rn_project_60\android.."):CreateProcess error=2, 系统找不到指定的文件

*:ReactNative:Cannot run program "./node_modules/.bin/react-native" (in directory "C:\Users\yelha\Desktop\rn_project_60\android.."): CreateProcess error=2, The system cannot find the file specified

:ReactNative:本地模块的自动导入失败.*

:ReactNative:Automatic import of native modules failed.*

配置项目:app

*:ReactNative:Cannot run program "./node_modules/.bin/react-native" (在目录 "C:\Users\yelha\Desktop\rn_project_60\android.."):CreateProcess error=2, 系统找不到指定的文件

*:ReactNative:Cannot run program "./node_modules/.bin/react-native" (in directory "C:\Users\yelha\Desktop\rn_project_60\android.."): CreateProcess error=2, The system cannot find the file specified

:ReactNative:本地模块的自动导入失败.*

:ReactNative:Automatic import of native modules failed.*

任务:app:installDebug

Task :app:installDebug

10:19:24 V/ddms:执行:运行 am get-config

10:19:24 V/ddms: execute: running am get-config

10:19:24 V/ddms:在5200127cb85a7465"上执行am get-config":EOF 命中.阅读:-1

10:19:24 V/ddms: execute 'am get-config' on '5200127cb85a7465' : EOF hit. Read: -1

10:19:24 V/ddms:执行:返回

10:19:24 V/ddms: execute: returning

在 'SM-A520F - 8.0.0' 上为 app:debug 安装 APK 'app-debug.apk'

Installing APK 'app-debug.apk' on 'SM-A520F - 8.0.0' for app:debug

10:19:24 D/app-debug.apk:将 app-debug.apk 上传到设备5200127cb85a7465"

10:19:24 D/app-debug.apk: Uploading app-debug.apk onto device '5200127cb85a7465'

10:19:24 D/设备:将文件上传到设备5200127cb85a7465"

10:19:24 D/Device: Uploading file onto device '5200127cb85a7465'

10:19:24 D/ddms: 读取 C:\Users\yelha\Desktop\rn_project_60\android\app\build\outputs\apk\debug\app-debug.apk 的文件权限为:rwx------

10:19:24 D/ddms: Reading file permision of C:\Users\yelha\Desktop\rn_project_60\android\app\build\outputs\apk\debug\app-debug.apk as: rwx------

10:19:26 V/ddms:执行:运行 pm install -r -t "/data/local/tmp/app-debug.apk"

10:19:26 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"

10:20:11 V/ddms:在 '5200127cb85a7465' 上执行 'pm install -r -t "/data/local/tmp/app-debug.apk"':EOF 命中.阅读:-1

10:20:11 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on '5200127cb85a7465' : EOF hit. Read: -1

10:20:11 V/ddms:执行:返回

10:20:11 V/ddms: execute: returning

10:20:11 V/ddms:执行:运行 rm "/data/local/tmp/app-debug.apk"

10:20:11 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk"

10:20:11 V/ddms:在 '5200127cb85a7465' 上执行 'rm "/data/local/tmp/app-debug.apk"':EOF 命中.阅读:-1

10:20:11 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on '5200127cb85a7465' : EOF hit. Read: -1

10:20:11 V/ddms:执行:返回安装在 1 台设备上.

10:20:11 V/ddms: execute: returning Installed on 1 device.

此版本中使用了弃用的 Gradle 功能,使其与 Gradle 6.0 不兼容.使用--warning-mode all"来显示单个弃用警告.请参阅 https://docs.gradle.org/5.4.1/用户指南/command_line_interface.html#sec:command_line_warnings

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

在 2m 2s 内构建成功28 个可操作任务:28 个已执行info 正在连接到开发服务器...info 在5200127cb85a7465"上启动应用程序...开始:意图 { cmp=com.rn_project_60/.MainActivity }136.52 秒内完成.

BUILD SUCCESSFUL in 2m 2s 28 actionable tasks: 28 executed info Connecting to the development server... info Starting the app on "5200127cb85a7465"... Starting: Intent { cmp=com.rn_project_60/.MainActivity } Done in 136.52s.

我使用版本:

react-native-cli: 2.0.1反应原生:0.60.0

react-native-cli: 2.0.1 react-native: 0.60.0

推荐答案

我刚刚遇到了同样的问题.解决办法如下:

I just experienced same issue. Here's the solution:

  1. 打开另一个命令行窗口
  2. 将目录更改为您的 React-Native 项目
  3. 键入:react-native start

在执行这些操作时保持您的应用打开,祝您好运!

Keep your app open while doing these, good luck!

这篇关于如何修复“ReactNative:无法运行程序"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆