nimiq / core-js

Official JavaScript implementation of the Nimiq protocol
https://nimiq.com
Other
989 stars 207 forks source link

Fails npm install nimiq #399

Closed caffeinum closed 6 years ago

caffeinum commented 6 years ago

New issue checklist

General information

Bug report

Expected behavior

Add nimiq module to the project as a dependency

Actual behavior

Crash.

Steps to reproduce

In the project, try adding nimiq

npm i nimiq

Crash log? Screenshots? Videos? Sample project?

$ npm i --save nimiq
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but npm-shrinkwrap.json was generated for lockfileVersion@0. I'll try to do my best with it!
npm WARN notice [SECURITY] bl has 1 moderate vulnerability. Go here for more details: https://nodesecurity.io/advisories?search=bl&version=0.8.2 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q== integrity checksum failed when using sha512: wanted sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q== but got sha1-EfgjGPX+e7LNIpZaEI6TBiCCFtg=. (1837200 bytes)
npm WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.

> leveldown@3.0.2 install /home/ubuntu/alpha.swap.online/node_modules/@nimiq/jungle-db/node_modules/leveldown
> prebuild-install || node-gyp rebuild

> node-lmdb@0.5.1 install /home/ubuntu/alpha.swap.online/node_modules/node-lmdb
> node-gyp rebuild

make: Entering directory '/home/ubuntu/alpha.swap.online/node_modules/node-lmdb/build'
  CC(target) Release/obj.target/node-lmdb/dependencies/lmdb/libraries/liblmdb/mdb.o
  CC(target) Release/obj.target/node-lmdb/dependencies/lmdb/libraries/liblmdb/midl.o
  CXX(target) Release/obj.target/node-lmdb/src/node-lmdb.o
  CXX(target) Release/obj.target/node-lmdb/src/env.o
../src/env.cpp: In lambda function:
../src/env.cpp:332:45: error: could not convert ‘* d->EnvSyncData::callback’ from ‘Nan::Callback’ to ‘v8::Local<v8::Function>’
         Nan::Call(*(d->callback), argc, argv);
                                             ^
node-lmdb.target.mk:115: recipe for target 'Release/obj.target/node-lmdb/src/env.o' failed
make: *** [Release/obj.target/node-lmdb/src/env.o] Error 1
make: Leaving directory '/home/ubuntu/alpha.swap.online/node_modules/node-lmdb/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/ubuntu/.nvm/versions/node/v9.11.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:180:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Linux 4.4.0-1057-aws
gyp ERR! command "/home/ubuntu/.nvm/versions/node/v9.11.1/bin/node" "/home/ubuntu/.nvm/versions/node/v9.11.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ubuntu/alpha.swap.online/node_modules/node-lmdb
gyp ERR! node -v v9.11.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm WARN @babel/plugin-check-constants@7.0.0-beta.38 requires a peer of @babel/core@7.0.0-beta.38 but none is installed. You must install peer dependencies yourself.
npm WARN ajv-keywords@3.1.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN swap@1.0.0 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-lmdb@0.5.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-lmdb@0.5.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2018-05-14T16_03_31_007Z-debug.log

Can attach debug.log file if needed.

caffeinum commented 6 years ago

The problem seems to be specific to our project, but it occurs on both Mac OS and Ubuntu.

In the fresh npm init project node-gyp fails too, but with another error:

> nimiq@1.0.1 install /Users/caffeinum/Web/empty/node_modules/nimiq
> node-gyp rebuild

make: *** No rule to make target `Release/obj.target/nimiq_node/src/native/argon2.o', needed by `Release/nimiq_node.node'.  Stop.
caffeinum commented 6 years ago

P.S. running npm install @nimiq/core gives the same error, yarn add nimiq too.

Though yarn add @nimiq/core seems to work.

sisou commented 6 years ago

The nimiq package is not maintained by the Nimiq team. The official packages are under the @nimiq namespace, such as @nimiq/core.

Can you please post the error you get when you npm install @nimiq/core? And on what OS and what node version are you on (because "it works for me")?

mrrovot commented 6 years ago

I get this error on osx el capitan 10.11.6 and node v8.11.2:

3 warnings generated.
  CC(target) Release/obj.target/node-lmdb/dependencies/lmdb/libraries/liblmdb/midl.o
  CXX(target) Release/obj.target/node-lmdb/src/node-lmdb.o
  CXX(target) Release/obj.target/node-lmdb/src/env.o
  CXX(target) Release/obj.target/node-lmdb/src/misc.o
../src/misc.cpp:28:8: error: thread-local storage is not supported for the current target
static thread_local uint32_t currentUint32Key = 0;
       ^
1 error generated.
make: *** [Release/obj.target/node-lmdb/src/misc.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:258: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 15.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/mrrovot/dev/nimiq/nimiq-wrapper/nimiqnode/node_modules/node-lmdb
sisou commented 6 years ago

@mrrovot It looks like the thread-local storage is not supported on your system. Quick googling of this error (error: thread-local storage is not supported for the current target) let me to here:

https://github.com/WebAssembly/binaryen/issues/1035 https://github.com/facebook/redex/issues/240

It seems like you need to update your XCode to version 8.x

caffeinum commented 6 years ago

@sisou image

I have the same error as @mrrovot

caffeinum commented 6 years ago

@sisou sorry, I can't reproduce this error, that may have been previous Nimiq version or another NodeJS version (v10 fails many other packages, e.g.).

However, I can't use @nimiq/core package for browser. Should it work in the React/Angular Webpack builds?

styppo commented 6 years ago

This seems to be resolved.