Closed appernetic closed 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
Which version of the aws-sdk did you use?
It would be great if we get a workaround. Downgrading to 2.177.0 doesn't seem to help.
I got the error when using the latest version. Then I downgraded to 2.177.0 and it worked.
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"
}
}
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
@appernetic @aloukissas Thanks for tracking it down on your end guys.
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.