React-native run-android失败

时间:2017-03-11 16:45:31

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

我已经被困了两天了,我正在尝试设置react-native,一切都到位:Uptodate Android Studio,Genymotion,路径和我遵循https://facebook.github.io/react-native/docs/getting-started.html上的所有指导 当我运行“react-native run-android”或“react-native start”时,我收到以下错误:C:\ Users \ Pc \ Desktop \ Bot> react-native run-android 该系统找不到指定的路径。 child_process.js:512     扔错了;     ^

错误:命令失败:C:\ Users \ Pc \ Desktop \ Bot \ node_modules \ react-native \ local-cli \ setup_env.bat 系统找不到指定的路径。

at checkExecSyncError (child_process.js:489:13)
at Object.execFileSync (child_process.js:509:13)
at Object.run (C:/Users/Pc/Desktop/Bot/node_modules/react-native/local-cli/cliEntry.js:136:16)
at Object.<anonymous> (C:\Users\Pc\AppData\Roaming\npm\node_modules\react-native-cli\index.js:117:7)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)

C:\ Users \ Pc \ Desktop \ Bot&gt; react-native start 该系统找不到指定的路径。 child_process.js:512     扔错了;     ^

错误:命令失败:C:\ Users \ Pc \ Desktop \ Bot \ node_modules \ react-native \ local-cli \ setup_env.bat 系统找不到指定的路径。

at checkExecSyncError (child_process.js:489:13)
at Object.execFileSync (child_process.js:509:13)
at Object.run (C:/Users/Pc/Desktop/Bot/node_modules/react-native/local-cli/cliEntry.js:136:16)
at Object.<anonymous> (C:\Users\Pc\AppData\Roaming\npm\node_modules\react-native-cli\index.js:117:7)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)

2 个答案:

答案 0 :(得分:0)

在明确配置react本机客户端的文件上注释一行是一个非常糟糕的主意。尝试从头开始创建一个新项目。也许你忘记了一个步骤或下载破了,你丢失了文件。

答案 1 :(得分:0)

在某处,react-native命令的环境路径没有正确设置。

您是否全局安装react-native-CLI?像:

$ npm install -g react-native-cli

确保正确设置Java变量的路径。 右键单击开始菜单,然后选择:   system-&gt;高级系统设置 - &gt;环境变量...... 路径应该转到JDK中的bin文件夹。

另外,请确保正确设置了ANDROID_HOME变量。 看到这个问题:

Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.