0

This has happened to me enough times that I figured it would be a public good to make a question out of it.

There is a npm package called scrypt which is used in a number of Ethereum related npm packages. scrypt, in turn, has a dependency called node-gyp. The node-gyp package has a high probability of failing in install in my experience. I know I've gotten around this in the past, and somehow gotten it to install, but I'm tired of reinventing the wheel every time I need it.

Relevant information:
OS: Debian 10
Node: 12.16.1

Relevant things I've done that haven't helped:

  • Installed globally
  • Updated the version of Python used to 3.x

What is the trick to getting it to install?

Here's the output of the last time it failed:

error /home/x/code/unifyadmin/packages/blockchain/node_modules/scrypt: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments: 
Directory: /home/x/code/unifyadmin/packages/blockchain/node_modules/scrypt
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@5.1.0
gyp info using node@12.16.1 | linux | x64
gyp info find Python using Python version 3.7.3 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/home/x/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/x/code/unifyadmin/packages/blockchain/node_modules/scrypt/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/x/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/x/.cache/node-gyp/12.16.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/x/.cache/node-gyp/12.16.1',
gyp info spawn args   '-Dnode_gyp_dir=/home/x/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/x/.cache/node-gyp/12.16.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/x/code/unifyadmin/packages/blockchain/node_modules/scrypt',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/x/code/unifyadmin/packages/blockchain/node_modules/scrypt/build'
  SOLINK_MODULE(target) Release/obj.target/copied_files.node
  COPY Release/copied_files.node
  CC(target) Release/obj.target/scrypt_wrapper/src/util/memlimit.o
  CC(target) Release/obj.target/scrypt_wrapper/src/scryptwrapper/keyderivation.o
  CC(target) Release/obj.target/scrypt_wrapper/src/scryptwrapper/pickparams.o
  CC(target) Release/obj.target/scrypt_wrapper/src/scryptwrapper/hash.o
  AR(target) Release/obj.target/scrypt_wrapper.a
  COPY Release/scrypt_wrapper.a
  CC(target) Release/obj.target/scrypt_lib/scrypt/scrypt-1.2.0/lib/crypto/crypto_scrypt.o
  CC(target) Release/obj.target/scrypt_lib/scrypt/scrypt-1.2.0/lib/crypto/crypto_scrypt_smix.o
  CC(target) Release/obj.target/scrypt_lib/scrypt/scrypt-1.2.0/libcperciva/util/warnp.o
  CC(target) Release/obj.target/scrypt_lib/scrypt/scrypt-1.2.0/libcperciva/alg/sha256.o
  CC(target) Release/obj.target/scrypt_lib/scrypt/scrypt-1.2.0/libcperciva/util/insecure_memzero.o
  CC(target) Release/obj.target/scrypt_lib/scrypt/scrypt-1.2.0/lib/scryptenc/scryptenc_cpuperf.o
  AR(target) Release/obj.target/scrypt_lib.a
  COPY Release/scrypt_lib.a
  CXX(target) Release/obj.target/scrypt/src/node-boilerplate/scrypt_common.o
In file included from ../src/node-boilerplate/scrypt_common.cc:28:
../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../nan/nan.h:2294:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
                                                              ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_common.cc:28:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = node::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<node::ObjectWrap>&)]’:
/home/x/.cache/node-gyp/12.16.1/include/node/node_object_wrap.h:85:78:   required from here
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:10226:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<node::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<node::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
                reinterpret_cast<Callback>(callback), type);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)]’:
../../nan/nan_object_wrap.h:65:61:   required from here
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:10226:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<Nan::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
  CXX(target) Release/obj.target/scrypt/src/node-boilerplate/scrypt_params_async.o
In file included from ../src/node-boilerplate/scrypt_params_async.cc:1:
../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../nan/nan.h:2294:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
                                                              ^
In file included from ../src/node-boilerplate/inc/scrypt_async.h:28,
                 from ../src/node-boilerplate/inc/scrypt_params_async.h:28,
                 from ../src/node-boilerplate/scrypt_params_async.cc:4:
../src/node-boilerplate/inc/scrypt_common.h: In constructor ‘NodeScrypt::Params::Params(const v8::Local<v8::Object>&)’:
../src/node-boilerplate/inc/scrypt_common.h:39:48: warning: ‘v8::Local<v8::Value> v8::Object::Get(v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
       N(obj->Get(Nan::New("N").ToLocalChecked())->Uint32Value()),
                                                ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/v8-internal.h:14,
                 from /home/x/.cache/node-gyp/12.16.1/include/node/v8.h:27,
                 from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:3553:51: note: declared here
   V8_DEPRECATED("Use maybe version", Local<Value> Get(Local<Value> key));
                                                   ^~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
In file included from ../src/node-boilerplate/inc/scrypt_async.h:28,
                 from ../src/node-boilerplate/inc/scrypt_params_async.h:28,
                 from ../src/node-boilerplate/scrypt_params_async.cc:4:
../src/node-boilerplate/inc/scrypt_common.h:39:63: error: no matching function for call to ‘v8::Value::Uint32Value()’
       N(obj->Get(Nan::New("N").ToLocalChecked())->Uint32Value()),
                                                               ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2707:41: note: candidate: ‘v8::Maybe<unsigned int> v8::Value::Uint32Value(v8::Local<v8::Context>) const’
   V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value(
                                         ^~~~~~~~~~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2707:41: note:   candidate expects 1 argument, 0 provided
In file included from ../src/node-boilerplate/inc/scrypt_async.h:28,
                 from ../src/node-boilerplate/inc/scrypt_params_async.h:28,
                 from ../src/node-boilerplate/scrypt_params_async.cc:4:
../src/node-boilerplate/inc/scrypt_common.h:40:48: warning: ‘v8::Local<v8::Value> v8::Object::Get(v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
       r(obj->Get(Nan::New("r").ToLocalChecked())->Uint32Value()),
                                                ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/v8-internal.h:14,
                 from /home/x/.cache/node-gyp/12.16.1/include/node/v8.h:27,
                 from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:3553:51: note: declared here
   V8_DEPRECATED("Use maybe version", Local<Value> Get(Local<Value> key));
                                                   ^~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
In file included from ../src/node-boilerplate/inc/scrypt_async.h:28,
                 from ../src/node-boilerplate/inc/scrypt_params_async.h:28,
                 from ../src/node-boilerplate/scrypt_params_async.cc:4:
../src/node-boilerplate/inc/scrypt_common.h:40:63: error: no matching function for call to ‘v8::Value::Uint32Value()’
       r(obj->Get(Nan::New("r").ToLocalChecked())->Uint32Value()),
                                                               ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2707:41: note: candidate: ‘v8::Maybe<unsigned int> v8::Value::Uint32Value(v8::Local<v8::Context>) const’
   V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value(
                                         ^~~~~~~~~~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2707:41: note:   candidate expects 1 argument, 0 provided
In file included from ../src/node-boilerplate/inc/scrypt_async.h:28,
                 from ../src/node-boilerplate/inc/scrypt_params_async.h:28,
                 from ../src/node-boilerplate/scrypt_params_async.cc:4:
../src/node-boilerplate/inc/scrypt_common.h:41:48: warning: ‘v8::Local<v8::Value> v8::Object::Get(v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
       p(obj->Get(Nan::New("p").ToLocalChecked())->Uint32Value()) {}
                                                ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/v8-internal.h:14,
                 from /home/x/.cache/node-gyp/12.16.1/include/node/v8.h:27,
                 from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:3553:51: note: declared here
   V8_DEPRECATED("Use maybe version", Local<Value> Get(Local<Value> key));
                                                   ^~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
In file included from ../src/node-boilerplate/inc/scrypt_async.h:28,
                 from ../src/node-boilerplate/inc/scrypt_params_async.h:28,
                 from ../src/node-boilerplate/scrypt_params_async.cc:4:
../src/node-boilerplate/inc/scrypt_common.h:41:63: error: no matching function for call to ‘v8::Value::Uint32Value()’
       p(obj->Get(Nan::New("p").ToLocalChecked())->Uint32Value()) {}
                                                               ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2707:41: note: candidate: ‘v8::Maybe<unsigned int> v8::Value::Uint32Value(v8::Local<v8::Context>) const’
   V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value(
                                         ^~~~~~~~~~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2707:41: note:   candidate expects 1 argument, 0 provided
In file included from ../src/node-boilerplate/inc/scrypt_params_async.h:28,
                 from ../src/node-boilerplate/scrypt_params_async.cc:4:
../src/node-boilerplate/inc/scrypt_async.h: In member function ‘virtual void ScryptAsyncWorker::HandleErrorCallback()’:
../src/node-boilerplate/inc/scrypt_async.h:53:29: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated [-Wdeprecated-declarations]
       callback->Call(1, argv);
                             ^
In file included from ../src/node-boilerplate/scrypt_params_async.cc:1:
../../nan/nan.h:1742:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
In file included from ../src/node-boilerplate/scrypt_params_async.cc:4:
../src/node-boilerplate/inc/scrypt_params_async.h: In constructor ‘ScryptParamsAsyncWorker::ScryptParamsAsyncWorker(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/node-boilerplate/inc/scrypt_params_async.h:35:36: error: no matching function for call to ‘v8::Value::NumberValue()’
       maxtime(info[0]->NumberValue()),
                                    ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2704:39: note: candidate: ‘v8::Maybe<double> v8::Value::NumberValue(v8::Local<v8::Context>) const’
   V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
                                       ^~~~~~~~~~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2704:39: note:   candidate expects 1 argument, 0 provided
In file included from ../src/node-boilerplate/scrypt_params_async.cc:4:
../src/node-boilerplate/inc/scrypt_params_async.h:36:39: error: no matching function for call to ‘v8::Value::NumberValue()’
       maxmemfrac(info[1]->NumberValue()),
                                       ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2704:39: note: candidate: ‘v8::Maybe<double> v8::Value::NumberValue(v8::Local<v8::Context>) const’
   V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
                                       ^~~~~~~~~~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2704:39: note:   candidate expects 1 argument, 0 provided
In file included from ../src/node-boilerplate/scrypt_params_async.cc:4:
../src/node-boilerplate/inc/scrypt_params_async.h:37:36: error: no matching function for call to ‘v8::Value::IntegerValue()’
       maxmem(info[2]->IntegerValue()),
                                    ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2705:40: note: candidate: ‘v8::Maybe<long int> v8::Value::IntegerValue(v8::Local<v8::Context>) const’
   V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
                                        ^~~~~~~~~~~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2705:40: note:   candidate expects 1 argument, 0 provided
In file included from ../src/node-boilerplate/scrypt_params_async.cc:4:
../src/node-boilerplate/inc/scrypt_params_async.h:38:39: error: no matching function for call to ‘v8::Value::IntegerValue()’
       osfreemem(info[3]->IntegerValue())
                                       ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2705:40: note: candidate: ‘v8::Maybe<long int> v8::Value::IntegerValue(v8::Local<v8::Context>) const’
   V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
                                        ^~~~~~~~~~~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:2705:40: note:   candidate expects 1 argument, 0 provided
../src/node-boilerplate/scrypt_params_async.cc: In member function ‘virtual void ScryptParamsAsyncWorker::HandleOKCallback()’:
../src/node-boilerplate/scrypt_params_async.cc:23:67: warning: ‘bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   obj->Set(Nan::New("N").ToLocalChecked(), Nan::New<Integer>(logN));
                                                                   ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/v8-internal.h:14,
                 from /home/x/.cache/node-gyp/12.16.1/include/node/v8.h:27,
                 from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:3499:22: note: declared here
                 bool Set(Local<Value> key, Local<Value> value));
                      ^~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
../src/node-boilerplate/scrypt_params_async.cc:24:64: warning: ‘bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   obj->Set(Nan::New("r").ToLocalChecked(), Nan::New<Integer>(r));
                                                                ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/v8-internal.h:14,
                 from /home/x/.cache/node-gyp/12.16.1/include/node/v8.h:27,
                 from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:3499:22: note: declared here
                 bool Set(Local<Value> key, Local<Value> value));
                      ^~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
../src/node-boilerplate/scrypt_params_async.cc:25:64: warning: ‘bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
   obj->Set(Nan::New("p").ToLocalChecked(), Nan::New<Integer>(p));
                                                                ^
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/v8-internal.h:14,
                 from /home/x/.cache/node-gyp/12.16.1/include/node/v8.h:27,
                 from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:3499:22: note: declared here
                 bool Set(Local<Value> key, Local<Value> value));
                      ^~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
../src/node-boilerplate/scrypt_params_async.cc:32:25: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated [-Wdeprecated-declarations]
   callback->Call(2, argv);
                         ^
In file included from ../src/node-boilerplate/scrypt_params_async.cc:1:
../../nan/nan.h:1742:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
In file included from /home/x/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/node-boilerplate/scrypt_params_async.cc:1:
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = node::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<node::ObjectWrap>&)]’:
/home/x/.cache/node-gyp/12.16.1/include/node/node_object_wrap.h:85:78:   required from here
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:10226:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<node::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<node::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
                reinterpret_cast<Callback>(callback), type);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)]’:
../../nan/nan_object_wrap.h:65:61:   required from here
/home/x/.cache/node-gyp/12.16.1/include/node/v8.h:10226:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<Nan::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
make: *** [scrypt.target.mk:131: Release/obj.target/scrypt/src/node-boilerplate/scrypt_params_async.o] Error 1
make: Leaving directory '/home/x/code/unifyadmin/packages/blockchain/node_modules/scrypt/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/x/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:311:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 4.19.0-10-amd64
gyp ERR! command "/home/x/.nvm/versions/node/v12.16.1/bin/node" "/home/x/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/x/code/unifyadmin/packages/blockchain/node_modules/scrypt
2
  • 1
    Please try to install it with Node v11
    – Jay
    Aug 19 '20 at 13:53
  • It should be fixed in web3 v1.2.9 for node 12, but if some dependency pulls an older version it will fail.
    – Ismael
    Aug 20 '20 at 4:22
2

Looking at the comments, two ideas were mentioned: I was running Node v12, and @Jay suggested downgrading to v11, and @Ismael suggested that the fail could be triggered by importing a web3 <1.2.9. As Ismael mentioned, this only helps if you're directly importing web3 - if a dependency is pulling in an older version of web3, it won't help. As it happens, in my personal setup the problems were being caused by a dependency.

Also, Node v11 gave me the same errors (based on an attempt on Sep 1, 2020). I next tried downporting to the last LTS before Erbium (12.13), which was Dunbium (10.13-10.22), and that worked, though.

I would like to emphasize that this answer may be somewhat ephemeral, as changes in dependencies and web3, or perhaps even in node-gyp and scrypt may completely solve or change the issue, but this did work for me today, so I figured I should leave it here in the case that others find it helpful.

Update / Side Note (October 2020): Nomic Labs announced the release of a library which serves a replacement for node-gyp called ethereum-cryptography. This is only a side note since it is of no help compiling projects that already incorporated node-gyp, but if you are building (buidling?) a new project, please see if you can avoid inflicting these traumas further, and to those who have blessed the ecosystem with their frameworks and tools, please, please make sure you're using ethereum-cryptography and not node-gyp.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.