aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.12k stars 579 forks source link

React-native | CognitoIdentityProviderClient | Unable to resolve module stream #4877

Closed roserens closed 1 year ago

roserens commented 1 year ago

Checkboxes for prior research

Describe the bug

Yesterday I updated my react-native app to version 0.72.0. Since then I get issues that modules can't be resolved when I try to run the Android emulator.

SDK version number

@aws-sdk/client-cognito-identity-provider@3.358.0

Which JavaScript Runtime is this issue in?

React Native

Details of the browser/Node.js/ReactNative version

0.72.0

Reproduction Steps

Reproduction steps

1) Install react native & aws sdk:

npx react-native@latest init Project --template react-native-template-typescript
npm install @aws-sdk/client-cognito-identity-provider

2) Add the following to the import section of to App.tsx:

    import {
        CognitoIdentityProviderClient,
        InitiateAuthCommandInput,
        InitiateAuthCommand,
        AuthFlowType
    } from "@aws-sdk/client-cognito-identity-provider";
    const region = "us-east-1";
    const cognitoClient = new CognitoIdentityProviderClient({
        region,
    });

3) Add the following code to the App function:

    const params: InitiateAuthCommandInput = {
        ClientId: "clientId",
        AuthFlow: AuthFlowType.USER_PASSWORD_AUTH,
        AuthParameters: {
            USERNAME: "username",
            PASSWORD: "password",
        },
    };
    const initiateAuthCommand = new InitiateAuthCommand(params);

    cognitoClient.send(initiateAuthCommand)

4) Then run the following commands:

npm start
npm run android

Observed Behavior

App does no longer launch. It gets the following error message:

image

Expected Behavior

App launches w/o error message.

Possible Solution

The simple solution seems to install the "stream" package. But then another module can't be loaded. Until it says it can't load the module "http". And then I didn't know what to do anymore.

Note that one month ago I didn't have any of those issues.

Additional Information/Context

Another user with a similar issue: https://github.com/aws/aws-sdk-js-v3/issues/3549

Unfortunately he didn't say how he solved his issue.