【问题标题】:ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. React Native in Visual Studio Code错误:未设置 JAVA_HOME,在您的 PATH 中找不到“java”命令。在 Visual Studio Code 中反应本机
【发布时间】:2022-07-20 23:31:33
【问题描述】:

我正在使用 Visual Studio 代码开发 React-native 应用程序和 nox 播放器作为 android 模拟器。我不想安装 Java SDK/JDK 来解决以下问题。我正在使用 yarnyarn android 命令在 android 模拟器 nox 播放器中运行应用程序。由于以下错误,我无法运行该应用程序。

› Building app...

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
C:\Users\...\android\gradlew.bat exited with non-zero code: 1        
Error: C:\Users\...\android\gradlew.bat exited with non-zero code: 1 
    at ChildProcess.completionListener (C:\Users\...\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\spawn-async\src\spawnAsync.ts:65:13)
    at Object.onceWrapper (node:events:642:26)        
    at ChildProcess.emit (node:events:527:28)
    at ChildProcess.cp.emit (C:\Users\...\AppData\Roaming\npm\node_modules\expo-cli\node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
    ...
    at spawnAsync (C:\Users\...\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\spawn-async\src\spawnAsync.ts:26:19)
    at spawnGradleAsync (C:\Users\...\AppData\Roaming\npm\node_modules\expo-cli\src\commands\run\android\spawnGradleAsync.ts:83:18)
    at assembleAsync (C:\Users\...\AppData\Roaming\npm\node_modules\expo-cli\src\commands\run\android\spawnGradleAsync.ts:57:16)
    at actionAsync (C:\Users\...\AppData\Roaming\npm\node_modules\expo-cli\src\commands\run\android\runAndroid.ts:143:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

【问题讨论】:

    标签: android react-native java-home nox


    【解决方案1】:

    Windows 11:

    解决方案:在 package.json 文件中,我已将 "main": "index.js" 更改为 "main": "node_modules/expo/AppEntry .js" 它对我有用。

    如果此解决方案对任何人都有帮助,那就太好了,如果有任何其他信息,请告诉我。

    【讨论】:

      猜你喜欢
      • 2021-05-31
      • 2019-01-22
      • 1970-01-01
      • 1970-01-01
      • 2018-06-26
      • 2021-01-29
      • 2018-05-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多