Android Studio setting node directory for build (Cause: error=2, No such file or directory)

一曲冷凌霜 提交于 2020-08-03 05:48:13

问题


My project build fails because it's using the incorrect directory to run Node. How do I go about setting the Node directory for these compile-time tasks?

The specific task is:

app:recordFilesBeforeBundleCommandDebug

And the related error:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:recordFilesBeforeBundleCommandDebug'.
Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'node''
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'node'
Caused by: java.io.IOException: Cannot run program "node" (in directory "/Users/me/Code/appname/android/app"): error=2, No such file or directory
Caused by: java.io.IOException: error=2, No such file or directory

回答1:


Add this to the build.gradle if you use React-Native

ext {    
    react = [
        nodeExecutableAndArgs:  ["/usr/local/bin/node"]
    ]
}



回答2:


I am running Android Studio on MacOS and following worked for me: Yoruba's answer above and starting the application from Terminal with open -a "Android Studio.app"




回答3:


I had the same problem and solved by installing node.js again because the react was not able to find it.



来源:https://stackoverflow.com/questions/53056842/android-studio-setting-node-directory-for-build-cause-error-2-no-such-file-or

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!