1

将纯 Nativescript 5.x 项目迁移到 Nativescript 6 使用 nativescript-nodeify (0.8.0) 、 sjcl (1.0.8) 和 uuid (3.3.3)
在 ios 或 android 上执行时,sjcl.random.randomWords(PBKDF2_SALT_SIZE) 是抛出错误 - JS 错误未准备好:生成器未播种

尝试了不同的方法在 webpack 中配置加密。仍然无法解决此错误!在这方面的任何帮助将不胜感激!!!

4

1 回答 1

2
Solution : https://stackoverflow.com/questions/53172766/how-to-use-ripple-lib-with-nativescript/53925032#53925032
1. Add NativeScript plugin to the project:
tns plugin add nativescript-randombytes
2. Create a file that will be a partial implementation of crypto module:
// Example path: project/app/shims/crypto.js
module.exports.randomBytes = require('nativescript-randombytes')
3. Add it to webpack.config.js in plugins configuration:
plugins: [
  ..., // other plugins
  new webpack.ProvidePlugin({
        crypto: resolve(__dirname, 'app/shims/crypto.js')
    })
]
4. Add resolve.alias for our version of crypto in webpack.config.js, so child dependencies require our crypto implementation:

alias: {
  ..., // Other aliases
  'crypto': resolve(__dirname, 'app/shims/crypto.js')
}
5. rm -rf platforms/android # or ios
   rm -rf hooks
   rm -rf node_modules
6. tns platform remove ios/android
7. tns platform add ios/android
8. tns build ios/android --bundle
9. tns run ios/android --bundle
于 2019-12-10T06:32:30.940 回答