0

I am receiving the following error when deploying and executing the CDK script yarn run build-env-dev. I have 3 package.json files (root, app and deploy directories) and i have updated the aws-cdk-lib package to version 2.79.1 from 2.12.0 in all 3 files. I also added the constructs 3.4.297 package to the root package.json file but this was not previously installed and i am not entirely convinced it is required? This cdk app was working and i cannot see any library changes in git. I'm relatively inexperienced with CDK, nodejs, yarn, typescript etc so any advice is appreciated.

yarn run v1.22.19
warning package.json: No license field
$ ./app/node_modules/.bin/tsc -p .
Error: deploy/node_modules/aws-cdk-lib/aws-iam/lib/grant.d.ts(2,22): error TS2305: Module '"constructs"' has no exported member 'IDependable'.
Error: deploy/node_modules/aws-cdk-lib/aws-iam/lib/principals.d.ts(1,10): error TS2305: Module '"constructs"' has no exported member 'IDependable'.
Error: deploy/node_modules/aws-cdk-lib/aws-s3/lib/destination.d.ts(1,21): error TS2305: Module '"constructs"' has no exported member 'IDependable'.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 2.

package.json (root directory)

    {
      "name": "msft-service",
      "version": "0.0.1",
      "bin": {
        "msft-service-cdk": "bin/msft-service-cdk.js"
      },
      "scripts": {
        "setup:all": "(yarn install) && (cd app && yarn install) && (cd deploy && yarn install)",
        "build-env-dev": "./app/node_modules/.bin/tsc -p .",
        "prepare-deploy": "&& yarn run prepare-deploy ./scripts/copy-modules.sh",
        "watch": "tsc -w",
        "test": "jest",
        "cdk": "cdk",
        "lint": "tslint '*.ts'",
        "lint-fix": "tslint --fix -p tsconfig.json"
      },
      "devDependencies": {
        "@aws-cdk/assert": "^1.103.0",
        "@types/aws-lambda": "^8.10.85",
        "@types/jest": "^26.0.10",
        "@types/node": "14.0.23",
        "aws-cdk": "^1.103.0",
        "constructs": "3.4.297",
        "esbuild": "^0.14.22",
        "jest": "^26.4.2",
        "ts-jest": "^26.2.0",
        "ts-node": "^10.2.1",
        "tslint": "^5.5.0",
        "typescript": "^4.2.4"
      },
      "dependencies": {
        "@aws-cdk/aws-apigateway": "^1.103.0",
        "@aws-cdk/aws-backup": "^1.103.0",
        "@aws-cdk/aws-dynamodb": "^1.103.0",
        "@aws-cdk/aws-ec2": "^1.103.0",
        "@aws-cdk/aws-events-targets": "^1.103.0",
        "@aws-cdk/aws-iam": "^1.103.0",
        "@aws-cdk/aws-lambda": "^1.103.0",
        "@aws-cdk/aws-lambda-event-sources": "^1.103.0",
        "@aws-cdk/aws-lambda-nodejs": "^1.103.0",
        "@aws-cdk/aws-logs": "^1.103.0",
        "@aws-cdk/aws-logs-destinations": "^1.103.0",
        "@aws-cdk/aws-route53": "^1.103.0",
        "@types/needle": "^2.0.4",
        "@types/xml2js": "^0.4.5",
        "aws-cdk-lib": "2.79.1",
        "aws-sdk": "^2.509.0",
        "batch-write-all": "1.0.2",
        "constructs": "3.4.297",
        "needle": "^2.3.3",
        "path": "^0.12.7",
        "source-map-support": "^0.5.16",
        "uuid": "3.4.0",
        "xml-js": "^1.6.11",
        "xml2js": "0.4.23"
      }
    }

package.json (app directory)

{
  "name": "msft-service",
  "version": "0.0.1",
  "bin": {
    "msft-service-cdk": "bin/msft-service-cdk.js"
  },
  "scripts": {
    "build-env-dev": "./app/node_modules/.bin/tsc -p .",
    "prepare-deploy": "&& yarn run prepare-deploy ./scripts/copy-modules.sh",
    "watch": "tsc -w",
    "test": "jest",
    "cdk": "cdk",
    "lint": "tslint '*.ts'",
    "lint-fix": "tslint --fix -p tsconfig.json"
  },
  "devDependencies": {
    "@aws-cdk/assert": "^1.103.0",
    "@types/aws-lambda": "^8.10.85",
    "@types/jest": "^26.0.10",
    "@types/node": "14.0.23",
    "aws-cdk": "^1.103.0",
    "esbuild": "^0.14.22",
    "jest": "^26.4.2",
    "ts-jest": "^26.2.0",
    "ts-node": "^10.2.1",
    "tslint": "^5.5.0",
    "typescript": "^4.2.4"
  },
  "dependencies": {
    "@aws-cdk/aws-apigateway": "^1.103.0",
    "@aws-cdk/aws-backup": "^1.103.0",
    "@aws-cdk/aws-dynamodb": "^1.103.0",
    "@aws-cdk/aws-ec2": "^1.103.0",
    "@aws-cdk/aws-events-targets": "^1.103.0",
    "@aws-cdk/aws-iam": "^1.103.0",
    "@aws-cdk/aws-lambda": "^1.103.0",
    "@aws-cdk/aws-lambda-event-sources": "^1.103.0",
    "@aws-cdk/aws-lambda-nodejs": "^1.103.0",
    "@aws-cdk/aws-logs": "^1.103.0",
    "@aws-cdk/aws-logs-destinations": "^1.103.0",
    "@aws-cdk/aws-route53": "^1.103.0",
    "@types/needle": "^2.0.4",
    "@types/xml2js": "^0.4.5",
    "aws-cdk-lib": "2.79.1",
    "aws-sdk": "^2.509.0",
    "batch-write-all": "1.0.2",
    "needle": "^2.3.3",
    "path": "^0.12.7",
    "source-map-support": "^0.5.16",
    "uuid": "3.4.0",
    "xml-js": "^1.6.11",
    "xml2js": "0.4.23"
  }
}

package.json (deploy directory)

{
  "name": "msft-service",
  "version": "0.0.1",
  "bin": {
    "msft-service-cdk": "bin/msft-service-cdk.js"
  },
  "scripts": {
    "build-env-dev": "./app/node_modules/.bin/tsc -p .",
    "prepare-deploy": "&& yarn run prepare-deploy ./scripts/copy-modules.sh",
    "watch": "tsc -w",
    "test": "jest",
    "cdk": "cdk",
    "lint": "tslint '*.ts'",
    "lint-fix": "tslint --fix -p tsconfig.json"
  },
  "devDependencies": {
    "@aws-cdk/assert": "^1.103.0",
    "@types/aws-lambda": "^8.10.85",
    "@types/jest": "^26.0.10",
    "@types/node": "14.0.23",
    "aws-cdk": "^1.103.0",
    "jest": "^26.4.2",
    "ts-jest": "^26.2.0",
    "ts-node": "^10.2.1",
    "typescript": "^4.2.4",
    "esbuild": "^0.14.22",
    "tslint": "^5.5.0"
  },
  "dependencies": {
    "@types/needle": "^2.0.4",
    "@types/xml2js": "^0.4.5",
    "@aws-cdk/aws-apigateway": "^1.103.0",
    "@aws-cdk/aws-dynamodb": "^1.103.0",
    "@aws-cdk/aws-ec2": "^1.103.0",
    "@aws-cdk/aws-iam": "^1.103.0",
    "@aws-cdk/aws-lambda": "^1.103.0",
    "@aws-cdk/aws-lambda-event-sources": "^1.103.0",
    "@aws-cdk/aws-route53": "^1.103.0",
    "@aws-cdk/aws-logs": "^1.103.0",
    "@aws-cdk/aws-logs-destinations": "^1.103.0",
    "@aws-cdk/aws-lambda-nodejs": "^1.103.0",
    "@aws-cdk/aws-events-targets": "^1.103.0",
    "@aws-cdk/aws-backup": "^1.103.0",
    "aws-sdk": "^2.509.0",
    "aws-cdk-lib": "2.79.1",
    "source-map-support": "^0.5.16",
    "uuid": "3.4.0",
    "xml2js": "0.4.23",
    "needle": "^2.3.3",
    "path": "^0.12.7",
    "xml-js": "^1.6.11",
    "batch-write-all": "1.0.2"
  }
}
BigRed247
  • 107
  • 2
  • 14
  • You have both CDK v1 and v2 installed. They cannot coexist. – gshpychka May 15 '23 at 18:29
  • 1
    Remove the v1 dependencies (e.g. `"@aws-cdk/aws-apigateway": "^1.103.0"`), which don't play nicely with v2. See the answers [here](https://stackoverflow.com/questions/75074108/aws-cdk-says-argument-of-type-this-is-not-assignable-to-parameter-of-type-con) and [here](https://stackoverflow.com/questions/70802742/cannot-find-httpapi-construct-in-cdk-v2/70803845#70803845). And the [migration guide](https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html) in the docs. – fedonev May 16 '23 at 09:45

0 Answers0