我的项目生成失败,因为它使用了不正确的目录来运行 node .如何为这些编译时任务设置 node 目录?

具体任务是:

应用程序:recordFilesBeforeBundleCommandDebug

以及相关的错误:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':应用程序: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

推荐答案

将此添加到构建中.gradle如果你用React Native

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

React-native相关问答推荐

Redux将旧状态迁移到新状态

React Native:任务 ':app:checkDebugDuplicateClasses' 执行失败

react-native-snap-carousel 无法正确渲染

在选项卡更改时react-navigation

警告:API 'variant.getMergeAssets()' 已过时 / Android Studio 3.3

React Native 入门元素Bundle 失败,出现 Unexpected Token 错误

中彼此相邻对齐(Align) react native

未找到 xcode 'boost/config/user.hpp' 文件

如何在 React Native 中本地存储不是字符串的数据

Undefined 不是判断 this.state.* 的对象

如何将 View 定位在 ScrollView 的底部?

在 Docker 中使用 Fastlane 构建 iOS 应用

如何在 React Native 中获取电话号码?

react-native async 函数返回 promise 但不返回我的 json 数据?

等待模块失效的超时

xcode 10错误:multiple commands produce

[React-Native][Jest]SyntaxError: Unexpected token import

使用 Jest 的 react-navigation 测试组件

Super expression must either be null or a function, not undefined

React Native:并排对齐两个 TextInput