执行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
解决方案
- 降级Node.js版本:Node v22属于非LTS版本,AWS CDK对其兼容性不足,建议切换到LTS版本(如v20.x或v18.x),可通过nvm-windows管理多版本Node。
- 清理并重建依赖:
- 删除项目根目录下的
node_modules文件夹和package-lock.json文件 - 执行
npm install重新安装依赖
- 删除项目根目录下的
- 验证.NET SDK兼容性:确保项目使用的.NET版本与CDK C#包兼容,可尝试指定项目使用.NET 6.0(初始化C# CDK项目默认版本),或升级CDK到最新兼容版本。
- 重新初始化项目:若项目文件存在损坏,删除现有项目目录,重新执行
cdk init app --language csharp,再依次执行dotnet build src和cdk synth。 - 检查环境变量:确认Node.js和npm的路径已正确添加到系统环境变量,无版本冲突。
内容的提问来源于stack exchange,提问作者Vitalii Ivanov
相关产品推荐
相关产品推荐

