React-Native ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your PATH.

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 Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.
运行react-native时候出现这个问题,

先检查是否已安装java jdk

并以配置好环境变量

git下载

配置环境变量

以win10为例

桌面》电脑》右击属性》高级系统设置》环境变量》系统变量
React-Native ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your PATH._第1张图片

点击新建

变量名:JAVA_HOME

路径:根据自己安装目录

React-Native ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your PATH._第2张图片

编辑path那个变量

React-Native ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your PATH._第3张图片
添加编辑==%JAVA_HOME%\bin==
React-Native ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your PATH._第4张图片重新打开cmd窗口

项目文件目录下 运行react-native run-android

你可能感兴趣的:(react,native)