Website-Integration

Bitcore = ‘錯誤:發現多個 bitcore-lib 實例’

  • January 14, 2022

這兩行(僅此而已)會產生錯誤:

var exp = require('bitcore-explorers');
var btc = require('bitcore-lib');

Error: More than one instance of bitcore-lib found. Please make sure to require bitcore-lib and check that submodules do not also include their own bitcore-lib dependency.

我可以看到這個問題已經被記錄在這裡,以及這里這裡。我閱讀了這些頁面,但我仍然無法克服這個問題。

有人可以幫忙嗎?嘗試導入不同的模組時怎麼辦bitcore

我不知道這是否是正確的方法,但它確實有效。

delete global._bitcore
var bitcore = require('bitcore-lib')

請參閱在位核定義之前添加此行:

Object.defineProperty(global, '_bitcore', { get(){ return undefined }, set(){} })

取自這裡

引用自:https://bitcoin.stackexchange.com/questions/46795