Home > Mobile >  ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. React Nativ
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. React Nativ

Time:07-21

I am using Visual studio code to develop React-native apps and nox player as android emulator. I don't want to install Java SDK/JDK to resolve the below issue. I am using yarn, and yarn android command in order to run the app in android simulator nox player. I couldn't run the app due to below error.

› 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.

CodePudding user response:

Windows 11:

Resolution: In package.json file I have changed "main": "index.js" to "main": "node_modules/expo/AppEntry.js" it worked for me.

It would be great if this solution helps anyone, let me know for any additional information.

CodePudding user response:

Are you using MacOS or Windows?

  • Related