cdktf synth fails with "error TS2305: Module has no exported member" for a provider resource
Fixes the TypeScript compile error during cdktf synth where a provider binding export is missing (e.g. Instance from ./.gen/providers/aws) because bindings are stale or the provider version changed. Covers re-running cdktf get, checking the generated exports, and aligning provider versions. Use when synth fails with TS2305 on a .gen import. Not for JSII runtime errors.
TL;DR
Re-run cdktf get to regenerate the provider bindings, then check that the export exists in .gen/providers/[name]. If the resource was renamed or removed in the provider version, update your import.
The error
main.ts(3,23): error TS2305: Module '"./.gen/providers/aws"' has no exported member 'Instance'.
...
cdktf encountered an error while synthesizing
Synth command: npx ts-node main.ts
Error: non-zero exit code 1Fix it
- Re-run
cdktf getto regenerate bindings from the provider schema. - Open
.gen/providers/aws/(or your provider's dir) and confirm whetherInstance(or your missing export) exists now. - If it exists, the old bindings were stale; re-run
cdktf synth. - If it still does not exist, the provider version removed/renamed it: check the provider changelog and update your code to the new construct name.
Expected result: tsc/ts-node compiles and synth proceeds.
When to use this
cdktf synthfails with TS2305 (or TS2307) naming a./.gen/...module- You upgraded the provider package or cdktf recently
When NOT to use this
- The error is a JSII runtime error (Missing required properties), which happens after compile
- The missing member is from your own code, not generated bindings
Root cause
.gen bindings are code-generated from the provider schema at cdktf get time. Upgrading @cdktf/provider-* without re-running cdktf get leaves bindings for the old schema, so imports of new/renamed resources fail type-checking. ts-node compiles main.ts before the jsii runtime ever runs, so the failure surfaces as a TS diagnostic.
Edge cases
- VS Code shows the same TS2305 inline; fixing the bindings fixes the editor too.
tsconfigpath issues can mimic this; verify the import path matches the generated directory layout first.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.