![](/img/trans.png)
[英]Android Studio 4 build failed cause error=2 no such file or directory
[英]Android Studio setting node directory for build (Cause: error=2, No such file or directory)
我的項目構建失敗,因為它使用了不正確的目錄來運行 Node。 go 如何為這些編譯時任務設置 Node 目錄?
具體任務是:
應用程序:recordFilesBeforeBundleCommandDebug
以及相關的錯誤:
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
我在 MacOS 上運行 Android Studio,以下對我open -a "Android Studio.app"
:Yoruba's answer above and open -a "Android Studio.app"
the application from Terminal with open -a "Android Studio.app"
如果您使用 React-Native,請將其添加到 build.gradle
ext {
react = [
nodeExecutableAndArgs: ["/usr/local/bin/node"]
]
}
我遇到了同樣的問題並通過再次安裝 node.js 解決了,因為 react 無法找到它。
這是環境的已知錯誤:
在 gradle-wrapper.properties 中升級到 Gradle 6.9 或更高版本
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-all.zip
使用命令查找系統中的節點路徑
which node
inside terminal 然后打開app/build.gradle
並添加這一行
ext {
react = [
nodeExecutableAndArgs: ["Node path from the above command"]
]
}
之后它可能會要求升級 kotlin 版本,然后將其添加到 build.gradle
buildscript {
ext {
kotlinVersion = "1.6.0"
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.