20 vue 使用bip32 创建btc钱包的问题

在创建btc钱包的时候 需要用到 bip32

  const root = bip32.fromSeed(seed, network)

在nodejs里使用下面方法 可以正常引入 bip32

const ecc = require('tiny-secp256k1')
const { BIP32Factory } = require('bip32')
// You must wrap a tiny-secp256k1 compatible implementation
const bip32 = BIP32Factory(ecc)

但是切换到vue环境,直接报错

ERROR in ./node_modules/tiny-secp256k1/lib/secp256k1.wasm 1:0
Module parse failed: Unexpected character ' ' (1:0)
The module seem to be a WebAssembly module, but module is not flagged as WebAssembly module for webpack.
BREAKING CHANGE: Since webpack 5 WebAssembly is not enabled by default and flagged as experimental feature.
You need to enable one of the WebAssembly experiments via 'experiments.asyncWebAssembly: true' (based on async modules) or 'experiments.syncWebAssembly: true' (like webpack 4, deprecated).
For files that transpile to WebAssembly, make sure to set the module type in the 'module.rules' section of the config (e. g. 'type: "webassembly/async"').
(Source code omitted for this binary file)
 @ ./node_modules/tiny-secp256k1/lib/wasm_loader.browser.js 4:0-41 5:15-19
 @ ./node_modules/tiny-secp256k1/lib/index.js 7:0-36 8:35-53 9:29-53 10:34-61 11:35-63 12:41-75 13:42-77 14:29-51 15:28-49 16:34-61 17:33-59 39:11-23 46:2-24 68:11-24 82:11-30 94:4-22 106:11-31 117:4-29 129:4-28 144:11-29 157:11-26 175:11-26 186:4-22 199:19-42 222:13-41 224:6-29 243:4-13 261:23-43 283:4-20 301:11-22 323:11-23 339:11-29

根据报错信息尝试更改webpack配置、引入wasm-loader 等方法,均未成功, 有相关经验的朋友,还望不吝赐教~

请先 登录 后评论

最佳答案 2022-11-30 11:00

未找到解决方案,暂时关闭~!

请先 登录 后评论

其它 0 个回答