You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行nx build命令失败,报TypeError: 无法读取undefined的'cloud'属性

解决 nx build 时的 "Cannot read properties of undefined (reading 'cloud')" 错误

可能的原因与修复步骤

  • 检查 nx-cloud 版本兼容性
    该错误多因 nx-cloud 与当前 Nx 版本不匹配引发。先查看项目 Nx 版本:

    nx --version
    

    安装与 Nx 版本匹配的 nx-cloud 包:

    npm install @nrwl/nx-cloud@<对应版本号> --save-dev
    

    或直接安装最新兼容版本:

    npm install @nrwl/nx-cloud@latest --save-dev
    
  • 清除依赖与构建缓存

    1. 删除依赖目录与锁文件:
      rm -rf node_modules package-lock.json yarn.lock
      
    2. 重新安装依赖:
      npm install
      
    3. 重置 Nx 构建缓存:
      nx reset
      
  • 校验配置文件中的任务 runner 配置
    检查 workspace.json 或 nx.json 里的 tasksRunnerOptions 配置,确保 nx-cloud runner 参数传递正确。示例配置:

    {
      "tasksRunnerOptions": {
        "default": {
          "runner": "@nrwl/nx-cloud",
          "options": {
            "cacheableOperations": ["build", "test", "lint"],
            "accessToken": "<你的访问令牌>"
          }
        }
      }
    }
    

    若无需 nx-cloud,可临时切换回默认 runner:

    {
      "tasksRunnerOptions": {
        "default": {
          "runner": "@nrwl/workspace/tasks-runners/default",
          "options": {
            "cacheableOperations": ["build", "test", "lint"]
          }
        }
      }
    }
    
  • 临时禁用 nx-cloud 执行
    运行构建命令时添加参数跳过 nx-cloud:

    nx build --cloud=false
    

内容的提问来源于stack exchange,提问作者Vivek Maru

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 23:10:55