aws-sdk-js-v3: [aws-sdk/client-cloudfront] typescript compile error on `node_modules/@aws-sdk/client-cloudfront/node_modules/@smithy/core/protocols.d.ts:6`

Checkboxes for prior research

Describe the bug

On compiling the typescript alerts an error on some modules on smithy dependency.


% tsc --noEmit 
node_modules/@aws-sdk/client-cloudfront/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'RequestBuilder'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@aws-sdk/client-cloudfront/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'collectBody'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@aws-sdk/client-cloudfront/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'extendedEncodeURIComponent'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@aws-sdk/client-cloudfront/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'requestBuilder'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@aws-sdk/client-cloudfront/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'resolvedPath'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 5 errors in the same file, starting at: node_modules/@aws-sdk/client-cloudfront/node_modules/@smithy/core/protocols.d.ts:6

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/client-cloudfront@3.699.0,

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

node=v20.16.0

Reproduction Steps

I’ve already used some aws-sdk packages in my project, but from now on, try to use the @aws-sdk/client-cloudfront@3.699.0 to compile breaks.

"dependencies": {
    "@aws-sdk/client-cloudfront": "^3.699.0",
    "@aws-sdk/client-cognito-identity-provider": "^3.441.0",
    "@aws-sdk/client-s3": "^3.481.0",
    "@aws-sdk/client-ses": "^3.441.0",
    "@aws-sdk/s3-presigned-post": "^3.485.0",
    "@aws-sdk/s3-request-presigner": "^3.682.0",    
    "ts-node": "^10.9.1",
    "typescript": "^5.2.2"
}

Observed Behavior

Found 5 errors in the same file, starting at: node_modules/@aws-sdk/client-cloudfront/node_modules/@smithy/core/protocols.d.ts:6

Expected Behavior

No compile error.

Possible Solution

No response

Additional Information/Context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 5
  • Comments: 16 (3 by maintainers)

Most upvoted comments

I posted this yesterday but had to do some extra verification. I now am confident this should solve the issue.

I think the issue here is the various different versions of the @aws-sdk packages specified in your dependencies. I was getting this issue because a subdependency of the CloudFront client had a clashing version of @aws-sdk/client-sts.

For example, if you’re using both @aws-sdk/client-cloudfront and @aws-sdk/client-sts you’ll have to make sure that the version of the @aws-sdk/client-sts dependency you’re specifying in your package.json is the same as the STS sub-dependancy used by @aws-sdk/client-cloudfront.

You can usenpm-why @smithy/core to see the various versions your aws deps are using. Otherwise pinning and using the same versions of all of these packages could be your solution here…

"dependencies": {
    "@aws-sdk/client-cloudfront": "3.699.0",
    "@aws-sdk/client-cognito-identity-provider": "3.669.0",
    "@aws-sdk/client-s3": "3.669.0",
    "@aws-sdk/client-ses": "3.669.0",
    "@aws-sdk/s3-presigned-post": "3.669.0",
    "@aws-sdk/s3-request-presigner": "3.669.0",    
    "ts-node": "^10.9.1",
    "typescript": "^5.2.2"
}

Thank you!, this is the actual root cause of the issue that helped fix the problem.

I had the same problems but I was able to get it working by:

  • npm cache clean --force
  • npm cache verify
  • rm -rf node_modules
  • rm -rf package-lock.json

And then redoing an npm install.

From my git diff, it looks like most of the changes were from package-lock.json with too many different package dependencies that required removal and changing when moving between the two versions (3.721.0 to 3.723.0) for the following packages:

Example of error - for @aws-sdk/client-cloudformation
> tsc

node_modules/@aws-sdk/client-cloudformation/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'RequestBuilder'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@aws-sdk/client-cloudformation/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'collectBody'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@aws-sdk/client-cloudformation/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'extendedEncodeURIComponent'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@aws-sdk/client-cloudformation/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'requestBuilder'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@aws-sdk/client-cloudformation/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'resolvedPath'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 5 errors in the same file, starting at: node_modules/@aws-sdk/client-cloudformation/node_modules/@smithy/core/protocols.d.ts:6

npm error code 1

My guess is there was quite a bit of a change to the dependency tree but I’m not too sure why.

I posted this yesterday but had to do some extra verification. I now am confident this should solve the issue.

I think the issue here is the various different versions of the @aws-sdk packages specified in your dependencies. I was getting this issue because a subdependency of the CloudFront client had a clashing version of @aws-sdk/client-sts.

For example, if you’re using both @aws-sdk/client-cloudfront and @aws-sdk/client-sts you’ll have to make sure that the version of the @aws-sdk/client-sts dependency you’re specifying in your package.json is the same as the STS sub-dependancy used by @aws-sdk/client-cloudfront.

You can usenpm-why @smithy/core to see the various versions your aws deps are using. Otherwise pinning and using the same versions of all of these packages could be your solution here…

"dependencies": {
    "@aws-sdk/client-cloudfront": "3.699.0",
    "@aws-sdk/client-cognito-identity-provider": "3.669.0",
    "@aws-sdk/client-s3": "3.669.0",
    "@aws-sdk/client-ses": "3.669.0",
    "@aws-sdk/s3-presigned-post": "3.669.0",
    "@aws-sdk/s3-request-presigner": "3.669.0",    
    "ts-node": "^10.9.1",
    "typescript": "^5.2.2"
}

I saw this same error, but it went away when I ran: npm install @smithy/core@latest

I just got this error after adding "@aws-sdk/client-cognito-identity-provider": "^3.699.0" to my dependencies @polkhovsky-norc’s "skipLibCheck": true seems to make the ts error go away.

Seeing the same error -

> tsc

../smithy/build/smithy/source/typescript-ssdk-codegen/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'RequestBuilder'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../smithy/build/smithy/source/typescript-ssdk-codegen/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'collectBody'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../smithy/build/smithy/source/typescript-ssdk-codegen/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'extendedEncodeURIComponent'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../smithy/build/smithy/source/typescript-ssdk-codegen/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'requestBuilder'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../smithy/build/smithy/source/typescript-ssdk-codegen/node_modules/@smithy/core/protocols.d.ts:6:3 - error TS2308: Module "@smithy/core/dist-types/submodules/protocols/index.d" has already exported a member named 'resolvedPath'. Consider explicitly re-exporting to resolve the ambiguity.

6   export * from "@smithy/core/dist-types/submodules/protocols/index.d";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 5 errors in the same file, starting at: ../smithy/build/smithy/source/typescript-ssdk-codegen/node_modules/@smithy/core/protocols.d.ts:6
  "dependencies": {
    "@aws-sdk/client-dynamodb": "^3.716.0",
    "@aws-sdk/util-dynamodb": "^3.716.0",
    "@types/aws-lambda": "^8.10.147",
    "@types/node": "^20.12.13"
  },

A temporal fix I did was to add; "exclude": ["node_modules/@smithy/core/protocols.d.ts"] to the tsconfig.json to bypass it