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

AWS CDK执行命令时遭遇stack.regionalFact函数不存在错误的求助

Solution for stack.regionalFact is not a function Error in AWS CDK 1.121.0

This error almost always stems from version mismatches between AWS CDK packages—specifically, when @aws-cdk/aws-iam (which calls stack.regionalFact) relies on a method that's missing in your installed version of @aws-cdk/core. Here's how to fix it:

Step 1: Ensure All CDK Packages Share the Exact Same Version

AWS CDK requires all @aws-cdk/* packages to be on the same version to maintain compatibility.

  1. Open your package.json file and check every entry starting with @aws-cdk/ (e.g., @aws-cdk/core, @aws-cdk/aws-lambda, @aws-cdk/aws-iam, @aws-cdk/aws-appsync). Make sure all of them are set to 1.121.0.
  2. If any packages have different versions, update them to match. For example:
    {
      "dependencies": {
        "@aws-cdk/core": "1.121.0",
        "@aws-cdk/aws-lambda": "1.121.0",
        "@aws-cdk/aws-iam": "1.121.0",
        "@aws-cdk/aws-appsync": "1.121.0",
        // other dependencies...
      }
    }
    
  3. Clean your existing dependencies and reinstall to ensure consistency:
    # Delete node_modules and lock file
    rm -rf node_modules package-lock.json
    # Reinstall dependencies
    npm install
    

Step 2: (Alternative) Upgrade to a More Stable 1.x CDK Version

Version 1.121.0 is relatively old and has known compatibility quirks. The 1.x line of CDK ended with version 1.199.0—upgrading to this version can resolve many such bugs:

  1. Upgrade the global CDK CLI:
    npm install -g aws-cdk@1.199.0
    
  2. Upgrade your project's CDK dependencies:
    npm install @aws-cdk/core@1.199.0 @aws-cdk/aws-lambda@1.199.0 @aws-cdk/aws-iam@1.199.0 @aws-cdk/aws-appsync@1.199.0
    
  3. Clean and reinstall dependencies as in Step 1.

Step 3: Verify the Fix

After completing either step above, try running your cdk deploy command again. The error should be resolved, and your Lambda function should deploy successfully alongside your AppSync API.


内容的提问来源于stack exchange,提问作者Muhammad Muaz

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.28 18:48:12