简体   繁体   English

NodeJS eth-lightwallet不允许子模块之间使用不同的bitcore-lib版本

[英]NodeJS eth-lightwallet doesn't allow different bitcore-lib versions among submodules

Module eth-lightwallet and its' dependencies have some issue with bitcore-lib version guard. 模块eth-lightwallet及其依赖项与bitcore-lib版本保护有关。 I noticed that some of them have version 0.15 and other 0.14. 我注意到其中一些版本为0.15,其他版本为0.14。 Do you have any solution to this problem? 您对此问题有解决方案吗? Error that I receive is presented below. 我收到的错误如下所示。

(function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync"]

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.
    at Object.bitcore.versionGuard (\GitHub\X\node_modules\eth-lightwallet\node_modules\bitcore-mnemonic\node_modules\bitcore-lib\index.js:12:11)
    at Object.<anonymous> (\GitHub\X\node_modules\eth-lightwallet\node_modules\bitcore-mnemonic\node_modules\bitcore-lib\index.js:15:9)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (\GitHub\X\node_modules\eth-lightwallet\node_modules\bitcore-mnemonic\lib\mnemonic.js:3:15)

Process finished with exit code 7`

Full proof solution 完整的解决方案

In your main file, set _bitcore in global to return undefined on every retrieval of its value. 在主文件中,将_bitcore设置为global以在每次检索其值时返回undefined。 _bitcore is not used for anything other than guarding version in bitcore-lib . _bitcore只能用于bitcore-lib中的保护版本。

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

The solution provided here worked for me: bitpay/bitcore#1454 这里提供的解决方案对我有用:bitpay / bitcore#1454

Well, this is far from a proper way to solve this issue, but you can get rid of this error by editing file 好吧,这远不是解决此问题的正确方法,但是您可以通过编辑文件来摆脱此错误

~/.nvm/versions/node/v4.8.3/lib/node_modules/bitcore/node_modules/insight-api/node_modules/bitcore-lib/index.js 〜/ .nvm / versions / node / v4.8.3 / lib / node_modules / bitcore / node_modules / insight-api / node_modules / bitcore-lib / index.js

line 7: bitcore.versionGuard = function(version) { Change it to: bitcore.versionGuard = function(version) { return; 第7行:bitcore.versionGuard = function(version){更改为:bitcore.versionGuard = function(version){return;

I did this and so far no problems. 我做到了,到目前为止没有问题。

This error causes of version confliction. 此错误导致版本冲突。 I fixed this error by changing the version of 我通过更改版本来解决此错误

bitcore-lib and bitcore-mnemonic/bitcore-lib by ^0.15.0 bitcore-libbitcore-mnemonic/bitcore-lib^0.15.0 bitcore-mnemonic/bitcore-lib

(which bitcore-mnemonic/bitcore-lib is ^0.16.0 ). (哪个bitcore-mnemonic/bitcore-lib^0.16.0 )。

Then npm install again. 然后再次npm install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM