bnb-chain / javascript-sdk

Javascript SDK to communicate with BNB Beacon Chain.
Apache License 2.0
381 stars 240 forks source link

Specify Node Version #243

Closed jchung00 closed 4 years ago

jchung00 commented 4 years ago

It seems like npm i @binance-chain/javascript-sdk causes errors on old versions of node. I was on v8.12.0 and ran into the error that I've pasted at the bottom. Updating to the latest versions worked. A colleague was on v10.x on node and it worked fine as well.

CXX(target) Release/obj.target/secp256k1/native/addon.o
../native/addon.cpp:18:1: error: unknown type name 'secp256k1_context'; did you mean 'secp256k1_context_t'?
secp256k1_context* context;
^~~~~~~~~~~~~~~~~
secp256k1_context_t
/usr/local/include/secp256k1.h:50:41: note: 'secp256k1_context_t' declared here
typedef struct secp256k1_context_struct secp256k1_context_t;
                                        ^
../native/addon.cpp:54:28: error: unknown type name 'secp256k1_pubkey'
        bool isPoint (const T& x, secp256k1_pubkey& pubkey) {
                                  ^
../native/addon.cpp:65:32: error: unknown type name 'secp256k1_ecdsa_signature'
        bool isSignature (const T& x, secp256k1_ecdsa_signature& signature) {
                                      ^
../native/addon.cpp:71:45: error: unknown type name 'secp256k1_pubkey'
        v8::Local<v8::Object> pointAsBuffer (const secp256k1_pubkey& public_key, const uint32_t flags) {
                                                   ^
../native/addon.cpp:80:63: error: use of undeclared identifier 'SECP256K1_EC_COMPRESSED'
                if (info.Length() <= index) return __isPointCompressed(p) ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED;
                                                                            ^
../native/addon.cpp:80:89: error: use of undeclared identifier 'SECP256K1_EC_UNCOMPRESSED'
                if (info.Length() <= index) return __isPointCompressed(p) ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED;
                                                                                                      ^
../native/addon.cpp:81:42: error: use of undeclared identifier 'SECP256K1_EC_COMPRESSED'
                if (info[index]->IsUndefined()) return SECP256K1_EC_COMPRESSED;
                                                       ^
../native/addon.cpp:82:75: error: use of undeclared identifier 'SECP256K1_EC_COMPRESSED'
                return info[index]->BooleanValue(Nan::GetCurrentContext()).FromJust() ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED;
                                                                                        ^
../native/addon.cpp:82:101: error: use of undeclared identifier 'SECP256K1_EC_UNCOMPRESSED'
                return info[index]->BooleanValue(Nan::GetCurrentContext()).FromJust() ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED;
                                                                                                                  ^
../native/addon.cpp:87:38: error: use of undeclared identifier 'SECP256K1_EC_COMPRESSED'
                if (info.Length() <= index) return SECP256K1_EC_COMPRESSED;
                                                   ^
../native/addon.cpp:88:42: error: use of undeclared identifier 'SECP256K1_EC_COMPRESSED'
                if (info[index]->IsUndefined()) return SECP256K1_EC_COMPRESSED;
                                                       ^
../native/addon.cpp:89:75: error: use of undeclared identifier 'SECP256K1_EC_COMPRESSED'
                return info[index]->BooleanValue(Nan::GetCurrentContext()).FromJust() ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED;
                                                                                        ^
../native/addon.cpp:89:101: error: use of undeclared identifier 'SECP256K1_EC_UNCOMPRESSED'
                return info[index]->BooleanValue(Nan::GetCurrentContext()).FromJust() ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED;
                                                                                                                  ^
../native/addon.cpp:100:2: error: unknown type name 'secp256k1_pubkey'
        secp256k1_pubkey public_key;
        ^
../native/addon.cpp:111:2: error: unknown type name 'secp256k1_pubkey'
        secp256k1_pubkey public_key;
        ^
../native/addon.cpp:134:2: error: unknown type name 'secp256k1_pubkey'
        secp256k1_pubkey a, b;
        ^
../native/addon.cpp:136:19: error: use of undeclared identifier 'b'
        if (!isPoint(pB, b)) return THROW_BAD_POINT;
                         ^
../native/addon.cpp:138:8: error: unknown type name 'secp256k1_pubkey'
        const secp256k1_pubkey* points[] = { &a, &b };
              ^
../native/addon.cpp:138:44: error: use of undeclared identifier 'b'
        const secp256k1_pubkey* points[] = { &a, &b };
                                                  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/secp256k1/native/addon.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/jaechung/LocalEOS/backend/server/node_modules/tiny-secp256k1
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tiny-secp256k1@1.1.3 build: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the tiny-secp256k1@1.1.3 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jaechung/.npm/_logs/2019-12-27T09_16_42_012Z-debug.log
secp256k1 bindings compilation fail. Pure JS implementation will be used.
xzjcool commented 4 years ago

Thanks for your suggestion, we will specify the node version. But it should be worked when node version > v6.x, I just run with CRA template with node version v8.12.0, it works except with some warning about tine-secp256k1. Can you provide more details?