skip to Main Content

I’ve pull a project that was working fine, however after doing the npm install; and then cdk synth; I’m getting a lot of could not resolve errors:

esbuild cannot run locally. Switching to Docker bundling.
✘ [ERROR] Could not resolve "@aws-sdk/core"

    var/runtime/node_modules/@aws-sdk/client-sts/dist-cjs/index.js:256:26:
      256 │ var import_core = require("@aws-sdk/core");
          ╵                           ~~~~~~~~~~~~~~~

  The module "./dist-es/index.js" was not found on the file system:

    var/runtime/node_modules/@aws-sdk/core/package.json:22:16:
      22 │       "module": "./dist-es/index.js",
         ╵                 ~~~~~~~~~~~~~~~~~~~~

  You can mark the path "@aws-sdk/core" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "@smithy/core"

    var/runtime/node_modules/@aws-sdk/client-cognito-identity/dist-cjs/index.js:76:26:
      76 │ var import_core = require("@smithy/core");
         ╵                           ~~~~~~~~~~~~~~

  The module "./dist-es/index.js" was not found on the file system:

    var/runtime/node_modules/@aws-sdk/node_modules/@smithy/core/package.json:20:16:
      20 │       "module": "./dist-es/index.js",
         ╵                 ~~~~~~~~~~~~~~~~~~~~

  You can mark the path "@smithy/core" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with 
a try/catch block to handle this failure at run-time instead of bundle-time.

I’m relatively new with cdk, so I’m not pretty sure what happened since there was not any code changes, I’m guessing that the dependencies that docker is trying to pull are missing…

I’ve tried many solutions from these links, with no luck:

2

Answers


  1. Chosen as BEST ANSWER

    I fixed this issue by installing esbuild to the project


  2. I had the same issue today with next versions:

    "@aws-sdk/client-cognito-identity-provider": "^3.321.1",
    "@aws-sdk/client-s3": "^3.226.0",
    "@aws-sdk/client-sqs": "^3.226.0",
    "@aws-sdk/s3-request-presigner": "^3.226.0",
    "aws-cdk-lib": "^2.118.0",
    

    I just uplifted them to:

    "aws-cdk-lib": "^2.158.0",
    "@aws-sdk/client-cognito-identity-provider": "^3.651.1"
    ...
    

    And issue gone
    I hope this helps you as well

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search