-
Notifications
You must be signed in to change notification settings - Fork 451
_global.util.crypto.lib.randomBytes is not a function error #646
Comments
Also seeing this issue, but am using 1.15.0. Upgrading to 1.19.0 does not fix it for me. I think you are right and its an issue with the aws-sdk dependency |
Just got the same issue, seems that the problem comes from the latest version of the depency |
I had to delete package-lock.json and change my package.json to (removed ^)
|
Following package.json worked for me:
Stack trace without a hard dependency on aws-sdk 2.177.0 and cognito 1.28.0:
|
I'm using:
with yarn and typescript with ts-loader and still the same error:
|
I suspect this is due to aws/aws-sdk-js@0638060 that was first introduced in aws-sdk v2.178.0. |
Totally broken. Rolling back doesn't solve the issue for me, either. Does anyone have a workaround? |
@aloukissas In case you are interested, this is what I've done: // aws-sdk-global-hack.ts
import * as aws from 'aws-sdk/global'
export * from 'aws-sdk/global'
export const util = aws['util'] // webpack.config.js
new webpack.NormalModuleReplacementPlugin(/^aws-sdk\/global$/, resource => {
if (resource.context.startsWith(path.join(__dirname, './node_modules/amazon-cognito-identity-js/'))) {
resource.request = path.join(__dirname, './scripts/aws-sdk-global-hack.ts')
}
}) |
Thanks @diegolacarta - I'm in a non-ejected CRA environment, so maybe this may not work for this case. I've manually pulled in the non-broken version of the aws-sdk within cognito, which fixes the issue. |
Adding |
@jogold doesn't work when using yarn. This is a showstopper. Can you please update the aws-sdk dep to a version that works with amazon-cognito-identity-js |
@realseanp As a workaround you can edit the dependencies in your |
@jkettmann I also edited the |
The main AWS Javascript SDK removed the dependency on crypto-browserify due to a reported vulnerability around the randomBytes method it implements: aws/aws-sdk-js#1856 We are aware of the issue at this point and are actively working on fixing it. As other developers mentioned, aws-sdk 2.177.0 works. |
If anyone is still having problems with the mentioned workarounds, I've created a fork of this library to use in a project that I'm working. This fork has the Just add Fork repo: https://github.com/ntocampos/amazon-cognito-identity-js |
@itrestian hopefully you'll be adding regression tests against aws-sdk (and hopefully for other deps, too) to prevent such show-stoppers in the future. |
As a temporary fix, we have locked down the AWS SDK version number to v2.177.0. Pulling in the latest version of this package should work. |
🚨 @itrestian installed 1.3.0 getting `Module not found: Error: Can't resolve 'amazon-cognito-identity-js'. Looks like the lib folder is missing from the package. |
I added the missing lib folder to the newest release. |
I saw same error. |
My story: Wasn't working, tried to change to many of the above mentioned versions, nothing seemed to work. Finally settled on the following:
And ran |
See #672 for a correct description and analysis. |
It worked for me by removing aws-sdk folder from node_modules. |
This has been solved in the new version 2.0.0 located on NPM and we will continue development of this library as part of AWS Amplfiy https://github.com/aws/aws-amplify/tree/master/packages/amazon-cognito-identity-js |
After upgrading to 1.29.0 I'm getting the following error when calling most functions
Rolling back to 1.19.0 fixes the issue
I suspect it's an aws-sdk issue but wondering if anyone else is seeing this issue and has a fix
The text was updated successfully, but these errors were encountered: