react-native找不到JAVA_HOME

时间:2019-09-09 16:15:17

标签: react-native react-native-android

使用react-native init AwesomeProject初始化项目后,我尝试通过react-native run-android在模拟器中运行它 但是我收到以下错误:

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.


error Failed to install the app. Make sure you have the Android development     environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

但是,我遵循Getting Started Guide并设置了JAVA_HOME环境变量,并且C:\Program Files\Java\jdk1.8.0_221\bin也位于路径变量中。

我正在Windows 10上使用WSL bash尝试此操作。

1 个答案:

答案 0 :(得分:0)

我能够通过创建一个新项目来解决此问题。问题是我在Windows中从WSL bash运行react-native init AwesomeProject。我可以重现这一点。 在命令提示符下运行相同的init命令时,它会起作用。