Closed sabinayakc closed 1 year ago
Does the problem exist as-well if you run npx ts-node -r tsconfig-paths/register --prefer-ts-exts src/main.ts
directly?
Ah I just saw your answer. It seems like the error stems from the app command, so there is not much cdktf itself can do here, we just execute this command you give us. The error looks like importing cdktf inside of the pre-built provider fails to resolve, in TS this can sometimes hint to a circular dependency if I recall correctly.
I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Community Note
cdktf & Language Versions
Affected Resource(s)
CDKTF Typescript
tsconfig file
,cdktf synth
throws error.// Not all constructs are taggable, so we need to filter it type TaggableConstruct = IConstruct & { tags?: { [key: string]: string }; tagsInput?: { [key: string]: string }; };
function isTaggableConstruct(x: IConstruct): x is TaggableConstruct { return "tags" in x && "tagsInput" in x; }
export class TagsAddingAspect implements IAspect { constructor(private tagsToAdd: Record<string, string>) {}
// This method is called on every Construct within the specified scope (resources, data sources, etc.). visit(node: IConstruct) { if (isTaggableConstruct(node)) { // We need to take the input value to not create a circular reference const currentTags = node.tagsInput || {}; this.tagsToAdd["name"] = node.node.id; node.tags = { ...this.tagsToAdd, ...currentTags }; } } }
⠋ Synthesizing [2022-10-31T10:37:56.103] [ERROR] default - /home/projects/github/metronet-iac-core/node_modules/@cdktf/provider-aws/src/provider/index.ts:3003 export class AwsProvider extends cdktf.TerraformProvider { ^ [2022-10-31T10:37:56.104] [ERROR] default - TypeError: Class extends value undefined is not a constructor or null at Object. (/home/projects/github/metronet-iac-core/node_modules/@cdktf/provider-aws/src/provider/index.ts:3003:40)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Object.require.extensions. [as .js] (/home/projects/github/metronet-iac-core/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/home/projects/github/metronet-iac-core/tgw-stack.ts:3:1)
ERROR: cdktf encountered an error while synthesizing
Synth command: npx ts-node -r tsconfig-paths/register --prefer-ts-exts src/main.ts Error: non-zero exit code 1
Aspects.of(stack).add( new TagsAddingAspect({ createdBy: "cdktf", environment: "global" }) );