回到这个问题上,以防万一有人卡住。解决方法是从根本上尝试在不同时间填充不同的包装以更改加载顺序。
当TYPED_ARRAY_SUPPORT被不同地对待并且Buffer更依赖于它时,我们尝试回到另一个版本。在旧版本中,我们尝试了许多不同的方法,最终放弃了,并通过将缓冲区更新到最新版本来回溯,最终一切正常。
我的意思是说,我们不确定如何解决它,但这是通过随机更改装载顺序直到幸运为止。我知道这不是一个很好的答案,但是我可以为这个问题提供最好的答案。
这就是我们的global.js最后的样子
// Inject node globals into React Native global scope.// Required for crypto functionality for bitcoinjs-lib, web3, etc.global.Buffer = require('buffer').Buffer;//global.Buffer.TYPED_ARRAY_SUPPORT = false;global.process = require('process');global.process.env.NODE_ENV = __DEV__ ? 'development' : 'production';var getRandomValues = function(byteArray) { var bytes = crypto.rng.randomBytes(byteArray.length); for (let i = 0; i < byteArray.length; i++) { byteArray[i] = bytes[i]; }};// "But Zach, aren't you just doing the same thing twice?"// Yes. Initializing the crypto-browserify module eventually requires// crypto.getRandomValues to exist, so we must add it here once.// However, crypto-browserify does not support getRandomValues, so we// must re-add it after loading the module.global.crypto = { getRandomValues };global.crypto.rng = require('react-native-randombytes');global.crypto = require('crypto');global.crypto.getRandomValues = getRandomValues;global.crypto.rng = require('react-native-randombytes');crypto.rng.seedSJCL();// Needed so that 'stream-http' chooses the right default protocol.global.location = { protocol: 'file:'};


