aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.05k stars 573 forks source link

Installing @aws-sdk/util-dynamodb for use with aws-sdk js v2 results in compilation errors #1858

Closed EricCrosson closed 3 years ago

EricCrosson commented 3 years ago

Describe the bug

SDK version number

3.1.0

Is the issue in the browser/Node.js/ReactNative?

Node.js

Details of the browser/Node.js/ReactNative version

λ node -v        
v14.15.3

To Reproduce (observed behavior)

I followed instruction from this comment: https://github.com/aws/aws-sdk-js/issues/3018#issuecomment-725817099

  1. in repository using "aws-sdk": "^2.787.0", install @aws-sdk/util-dynamodb v 3.1.0
  2. run npx tsc

This results in the following compilation errors from within the @aws-sdk/util-dynamodb package:

> tsc -b .../../node_modules/@aws-sdk/util-dynamodb/dist/cjs/marshall.d.ts:1:32 - error TS2307: Cannot find module '@aws-sdk/client-dynamodb' or its corresponding type declarations.1 import { AttributeValue } from "@aws-sdk/client-dynamodb";                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~../../node_modules/@aws-sdk/util-dynamodb/dist/cjs/convertToAttr.d.ts:1:32 - error TS2307: Cannot find module '@aws-sdk/client-dynamodb' or its corresponding type declarations.1 import { AttributeValue } from "@aws-sdk/client-dynamodb";                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~../../node_modules/@aws-sdk/util-dynamodb/dist/cjs/unmarshall.d.ts:1:32 - error TS2307: Cannot find module '@aws-sdk/client-dynamodb' or its corresponding type declarations.

1 import { AttributeValue } from "@aws-sdk/client-dynamodb";
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~

../../node_modules/@aws-sdk/util-dynamodb/dist/cjs/convertToNative.d.ts:1:32 - error TS2307: Cannot find module '@aws-sdk/client-dynamodb' or its corresponding type declarations.

1 import { AttributeValue } from "@aws-sdk/client-dynamodb";

Expected behavior

I expected compilation to succeed.

Additional context

If there is a dependency on the client-dynamodb package from the util-dynamodb package, maybe expressing this as a range in the peerDependency field of the util-dynamodb package.json would suffice. npm 7 would then resolve this peerDependency during npm install and there would be no error.

Note that installing @aws-sdk/client-dynamodb I get a different error:

node_modules/@aws-sdk/client-dynamodb/types/DynamoDBClient.d.ts:58:304 - error TS2305: Module '"../../types/dist/cjs"' has no exported member 'UserAgent'.

58 import { Provider, RegionInfoProvider, Credentials as __Credentials, Decoder as __Decoder, Encoder as __Encoder, HashConstructor as __HashConstructor, HttpHandlerOptions as __HttpHandlerOptions, Logger as __Logger, Provider as __Provider, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent } from "@aws-sdk/types";
                                                                                                                                                                                                                                                                                                                  ~~~~~~~~~

node_modules/@aws-sdk/middleware-user-agent/dist/cjs/configurations.d.ts:1:20 - error TS2305: Module '"../../../types/dist/cjs"' has no exported member 'UserAgent'.

1 import { Provider, UserAgent } from "@aws-sdk/types";

which I am less certain how to get past. This one seems like an internal bug

Update: this second bug is already reported

EricCrosson commented 3 years ago

The second bug mentioned appears to be this one: https://github.com/aws/aws-sdk-js-v3/issues/1842, so no need to focus on it here. This workaround worked for me.

AllanZhengYP commented 3 years ago

The root cause for this issue seems to be duplicated with #1842. We will make comments there as we progress.

EricCrosson commented 3 years ago

Agreed, ok thanks. Will close this ticket out then

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.