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

执行AWS CDK C#示例教程时遇Amazon.JSII.Runtime.JsiiError错误求助

AWS CDK C#项目执行cdk synth/list时触发JsiiError错误

操作步骤

  • 执行 cdk init app --language csharp
  • 执行 dotnet build src
  • 执行 cdk synth 或 cdk list 时触发错误

错误日志

Unhandled exception. Amazon.JSII.Runtime.JsiiError: Child process exited unexpectedly!
   at Amazon.JSII.Runtime.Services.Runtime.ReadResponse()
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Services.Client.Hello()
   at Amazon.JSII.Runtime.Services.ServiceContainer.BuildServiceProvider(ILoggerFactory loggerFactoryOverride)
   at Amazon.JSII.Runtime.Services.ServiceContainer.<>c.<.cctor>b__8_0()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at Amazon.JSII.Runtime.Services.ServiceContainer.get_ServiceProvider()
   at Amazon.JSII.Runtime.Deputy.JsiiTypeAttributeBase.Load(Assembly assembly)
   at Amazon.JSII.Runtime.Deputy.JsiiTypeAttributeBase.Load(Assembly assembly)
   at Amazon.JSII.Runtime.Deputy.DeputyBase..ctor(DeputyProps props)
   at Constructs.Construct..ctor(DeputyProps props)
   at Amazon.CDK.Stage..ctor(DeputyProps props)
   at Amazon.CDK.App..ctor(IAppProps props)
   at CdkWorkshop.Program.Main(String[] args) in C:\Development\cdk-workshop\src\CdkWorkshop\Program.cs:line 12

Subprocess exited with error 3762504530

环境信息

  • CDK版本 - 2.149.0 (build c8e5924)
  • npm版本 - 10.8.2
  • node版本 - v22.5.0
  • Windows 11 - 22H2 (22621.3880)
  • .NET SDK:6.0.424、8.0.303

解决方案

  1. 降级Node.js版本:Node v22属于非LTS版本,AWS CDK对其兼容性不足,建议切换到LTS版本(如v20.x或v18.x),可通过nvm-windows管理多版本Node。
  2. 清理并重建依赖:
    • 删除项目根目录下的node_modules文件夹和package-lock.json文件
    • 执行 npm install 重新安装依赖
  3. 验证.NET SDK兼容性:确保项目使用的.NET版本与CDK C#包兼容,可尝试指定项目使用.NET 6.0(初始化C# CDK项目默认版本),或升级CDK到最新兼容版本。
  4. 重新初始化项目:若项目文件存在损坏,删除现有项目目录,重新执行cdk init app --language csharp,再依次执行dotnet build src和cdk synth。
  5. 检查环境变量:确认Node.js和npm的路径已正确添加到系统环境变量,无版本冲突。

内容的提问来源于stack exchange,提问作者Vitalii Ivanov

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 21:50:01