AnomalyInnovations / serverless-stack-demo-client

Source for the demo app client in the Serverless Stack Guide
https://demo2.serverless-stack.com
MIT License
635 stars 204 forks source link

TypeError: __WEBPACK_IMPORTED_MODULE_0_aws_sdk_global__.util.crypto.lib.randomBytes is not a function #19

Closed appernetic closed 6 years ago

appernetic commented 6 years ago

I followed the guide: https://serverless-stack.com/chapters/create-a-new-reactjs-app.html

and got this error on the login with AWS Cognito section:

TypeError: WEBPACK_IMPORTED_MODULE_0_aws_sdk_global.util.crypto.lib.randomBytes is not a function

Then I downloaded the whole project installed and run it and got the same error.

appernetic commented 6 years ago

Solved by downgrading AWS SDK. There is a bug in latest version: https://stackoverflow.com/questions/48174252/util-crypto-lib-randombytes-is-not-a-function-aws-cognito-js-throws-error-on

https://github.com/aws/amazon-cognito-identity-js/issues/646

aloukissas commented 6 years ago

Which version of the aws-sdk did you use?

aloukissas commented 6 years ago

It would be great if we get a workaround. Downgrading to 2.177.0 doesn't seem to help.

appernetic commented 6 years ago

I got the error when using the latest version. Then I downgraded to 2.177.0 and it worked.

appernetic commented 6 years ago

This is my package.json for the serverless-stack-demo-client:

{
  "name": "app-client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "amazon-cognito-identity-js": "^1.29.0",
    "react": "^16.2.0",
    "react-bootstrap": "^0.32.0",
    "react-dom": "^16.2.0",
    "react-router-dom": "^4.2.2",
    "react-scripts": "1.0.17"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}
aloukissas commented 6 years ago

This didn't fix it for me. What did fix it: I had to manually tell amazon-cognito-identity-js to pull aws-sdk 2.176.0 and redo npm install within node_modules/amazon-cognito-identity-js

jayair commented 6 years ago

@appernetic @aloukissas Thanks for tracking it down on your end guys.