AWS JS SDK throws Uncaught TypeError: Unable to read 'crypto' property from undefined

My following code:

var AWS = require('./aws-sdk-2.2.10.js') // THIS LINE ERRORS 

It produces the following error:

 Uncaught TypeError: Cannot read property 'crypto' of undefined 

This is the part of aws-sdk-2.2.10.js that throws an error

 ... 65: [function(require, module, exports) { (function() { var _global = this; // I think 'this' is undefined here var mathRNG, whatwgRNG; mathRNG = function(size) { var bytes = new Array(size); var r; for (var i = 0, r; i < size; i++) { if ((i & 0x03) == 0) r = Math.random() * 0x100000000; bytes[i] = r >>> ((i & 0x03) << 3) & 0xff; } return bytes; } ; if (_global.crypto && crypto.getRandomValues) { // THIS LINE ERRORS whatwgRNG = function(size) { var bytes = new Uint8Array(size); crypto.getRandomValues(bytes); return bytes; } ; } module.exports = whatwgRNG || mathRNG; } )(); } ... 

My code is built through webpack, and my code is in the app.js. record file

I'm not sure why this will not work?

Edit: if that matters, my ultimate goal is to use Parse CloudCode to host and retrieve files from s3

+5
source share

Source: https://habr.com/ru/post/1233910/


All Articles