Gradle sync stop working with "Cannot run program "node" message
See original GitHub issueEnvironment
System: OS: macOS 11.4 CPU: (8) arm64 Apple M1 Memory: 123.39 MB / 8.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.5.0 - /opt/homebrew/bin/node Yarn: 1.22.11 - /opt/homebrew/bin/yarn npm: 7.19.1 - /opt/homebrew/bin/npm Watchman: 4.9.0 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.10.1 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4 Android SDK: API Levels: 29, 31 Build Tools: 29.0.2, 31.0.0 System Images: android-29 | Intel x86 Atom_64, android-31 | Google APIs ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7583922 Xcode: 12.5/12E262 - /usr/bin/xcodebuild Languages: Java: 1.8.0_282 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: 0.64.2 => 0.64.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Description
Hey, everyone. Surprisingly for me launching project with android studio stopped to work with gradle sync error. But I still can run project with npx react-native run-android
Caused by: java.io.IOException: Cannot run program "node" (in directory "/Users/zigi/Temp/droidSuck/android"): error=2, No such file or directory
at java_lang_Runtime$exec$0.call(Unknown Source)
at ReactNativeModules.getCommandOutput(/Users/zigi/Temp/droidSuck/node_modules/@react-native-community/cli-platform-android/native_modules.gradle:189)
at ReactNativeModules$getCommandOutput$0.callCurrent(Unknown Source)
at ReactNativeModules.getReactNativeConfig(/Users/zigi/Temp/droidSuck/node_modules/@react-native-community/cli-platform-android/native_modules.gradle:233)
at ReactNativeModules$getReactNativeConfig.callCurrent(Unknown Source)
at ReactNativeModules.<init>(/Users/zigi/Temp/droidSuck/node_modules/@react-native-community/cli-platform-android/native_modules.gradle:84)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at native_modules_btdx1fw5o90mtgvk8m0ztnv6f.run(/Users/zigi/Temp/droidSuck/node_modules/@react-native-community/cli-platform-android/native_modules.gradle:287)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 159 more
Caused by: java.io.IOException: error=2, No such file or directory
I found a workaround - I can launch the android studio from the terminal and error is gone, so my bet it’s doesn’t see node binary from brew folder, but I have no idea why this is happening and why it works before and suddenly stops
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:14 (1 by maintainers)
Top GitHub Comments
I am using “Android Studio Bumblebee | 2021.1.1”. it works for me
sudo chmod +x /Applications/Android\ Studio.app/Contents/bin/printenv
Also need to restart the Android Studio after the above comment
more info: https://stackoverflow.com/a/70891538/2558451
note: this bug was fixed in Android Studio Bumblebee | 2021.1.1 Patch 1 https://developer.android.com/studio/releases#bumblebee
Hi all, I was able to resolve the issue by updating my Gradle version used.
File > Project Structure > Project
then under Gradle Version I chose 6.9-rc-1You can also update it in
android/gradle/wrapper/gradle-wrapper.properties
file.Edit: Also in my case, the project I was working on used a very old version of gradle. The above solution above might work on others i.e. symlinks and making sure your node installation is correct.