question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gyp build error on Mac with usb native module

See original GitHub issue
  • Version: 20.28.3
  • Target: mac

Running ./node_modules/.bin/electron-builder results in an error that I can’t reproduce if I run the same command again.

This happens after rebuilding native production dependencies platform=darwin arch=x64

The essence is app/package.json contains "usb": "^1.3.3" and the error looks like it’s an rm failure from the Makefile.

rm: ./Release/.deps/Release/obj.target/libusb/libusb/libusb/core.o.d.raw: No such file or directory
make: *** [Release/obj.target/libusb/libusb/libusb/core.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2

If I cd /Users/user/myapp/app/node_modules/usb and run the command "/usr/local/Cellar/node/10.7.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/user/myapp/app/node_modules/usb/src/binding/usb_bindings.node" "--module_name=usb_bindings" "--module_path=/Users/user/myapp/app/node_modules/usb/src/binding" "--napi_version=3" "--node_abi_napi=napi" it doesn’t error. However, it doesn’t fix the issue and electron-builder continues to error on packaging.

gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@10.7.0 | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Nothing to be done for `all'.
gyp info ok 

Here’s output of the gyp configure/build commands run in isolation. They all succeed.

users-mbp:usb user$ "/usr/local/Cellar/node/10.7.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/user/myapp/app/node_modules/usb/src/binding/usb_bindings.node" "--module_name=usb_bindings" "--module_path=/Users/user/myapp/app/node_modules/usb/src/binding" "--napi_version=3" "--node_abi_napi=napi"
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@10.7.0 | darwin | x64
gyp info spawn /usr/local/bin/python2
gyp info spawn args [ '/usr/local/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   '/Users/user/myapp/app/node_modules/usb/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/user/.node-gyp/10.7.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/user/.node-gyp/10.7.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/user/.node-gyp/10.7.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/user/myapp/app/node_modules/usb',
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 ok 


users-mbp:usb user$ "/usr/local/Cellar/node/10.7.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/user/myapp/app/node_modules/usb/src/binding/usb_bindings.node" "--module_name=usb_bindings" "--module_path=/Users/user/myapp/app/node_modules/usb/src/binding" "--napi_version=3" "--node_abi_napi=napi"
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@10.7.0 | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/libusb/libusb/libusb/core.o
../libusb/libusb/core.c:2241:35: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
        if (header_len < 0 || header_len >= sizeof(buf)) {
                              ~~~~~~~~~~ ^  ~~~~~~~~~~~
../libusb/libusb/core.c:2250:44: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
        if (text_len < 0 || text_len + header_len >= sizeof(buf)) {
                            ~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~
2 warnings generated.
  CC(target) Release/obj.target/libusb/libusb/libusb/descriptor.o
  CC(target) Release/obj.target/libusb/libusb/libusb/hotplug.o
  CC(target) Release/obj.target/libusb/libusb/libusb/io.o
  CC(target) Release/obj.target/libusb/libusb/libusb/strerror.o
  CC(target) Release/obj.target/libusb/libusb/libusb/sync.o
  CC(target) Release/obj.target/libusb/libusb/libusb/os/poll_posix.o
  CC(target) Release/obj.target/libusb/libusb/libusb/os/threads_posix.o
  CC(target) Release/obj.target/libusb/libusb/libusb/os/darwin_usb.o
../libusb/libusb/os/darwin_usb.c:344:3: warning: 'objc_registerThreadWithCollector' is deprecated: it does nothing. Define OBJC_SILENCE_GC_DEPRECATIONS=1 to temporarily silence this diagnostic.
      [-Wdeprecated-declarations]
  objc_registerThreadWithCollector();
  ^
/usr/include/objc/objc-auto.h:242:1: note: 'objc_registerThreadWithCollector' has been explicitly marked deprecated here
OBJC_GC_DEPRECATED("it does nothing")
^
/usr/include/objc/objc-auto.h:45:55: note: expanded from macro 'OBJC_GC_DEPRECATED'
#   define OBJC_GC_DEPRECATED(message) __attribute__((deprecated(message ". Define OBJC_SILENCE_GC_DEPRECATIONS=1 to temporarily silence this diagnostic.")))
                                                      ^
../libusb/libusb/os/darwin_usb.c:1281:27: warning: expression which evaluates to zero treated as a null pointer constant of type 'IOUSBInterfaceInterface550 **'
      (aka 'struct IOUSBInterfaceStruct550 **') [-Wnon-literal-null-conversion]
  cInterface->interface = IO_OBJECT_NULL;
                          ^~~~~~~~~~~~~~
/System/Library/Frameworks/IOKit.framework/Headers/IOTypes.h:164:24: note: expanded from macro 'IO_OBJECT_NULL'
#define IO_OBJECT_NULL  ((io_object_t) 0)
                        ^~~~~~~~~~~~~~~~~
2 warnings generated.
  LIBTOOL-STATIC Release/usb.a
  CXX(target) Release/obj.target/usb_bindings/src/node_usb.o
../src/node_usb.cc:151:7: warning: 'MakeCallback' is deprecated [-Wdeprecated-declarations]
        Nan::MakeCallback(Nan::New(hotplugThis), "emit", 2, argv);
             ^
../../nan/nan.h:1000:3: note: 'MakeCallback' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
  ^
../../nan/nan.h:102:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
1 warning generated.
  CXX(target) Release/obj.target/usb_bindings/src/device.o
../src/device.cc:237:9: warning: 'MakeCallback' is deprecated [-Wdeprecated-declarations]
                        Nan::MakeCallback(device, Nan::New(baton->callback), 1, argv);
                             ^
../../nan/nan.h:958:3: note: 'MakeCallback' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
  ^
../../nan/nan.h:102:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
1 warning generated.
  CXX(target) Release/obj.target/usb_bindings/src/transfer.o
../src/transfer.cc:126:8: warning: 'MakeCallback' is deprecated [-Wdeprecated-declarations]
                Nan::MakeCallback(self->handle(), Nan::New(self->v8callback), 3, argv);
                     ^
../../nan/nan.h:958:3: note: 'MakeCallback' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
  ^
../../nan/nan.h:102:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
1 warning generated.
  SOLINK_MODULE(target) Release/usb_bindings.node
  COPY /Users/user/myapp/app/node_modules/usb/src/binding/usb_bindings.node
  TOUCH Release/obj.target/action_after_build.stamp
gyp info ok 

Moreover, if I cd into app/node_modules/usb, both of these commands succeed:

node-pre-gyp install --fallback-to-build
node-pre-gyp install --update-binary

What’s very strange is I remember having this same bug a few weeks ago and it was resolved with something simple like removing ./node_modules and ./app/node_modules, removing package-lock.json, ~/.npm, .node-gyp, etc… but I’ve tried all of these and still no luck.

Another observation is that I must run npm install within app/ before I run it in the project root.

Any ideas?

> usb@1.3.3 install /Users/user/myapp/app/node_modules/usb
> node-pre-gyp install --fallback-to-build

  CC(target) Release/obj.target/libusb/libusb/libusb/core.o
  CC(target) Release/obj.target/libusb/libusb/libusb/core.o
  CC(target) Release/obj.target/libusb/libusb/libusb/descriptor.o
Failed to execute '/usr/local/Cellar/node/10.7.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/user/myapp/app/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/Users/user/myapp/app/node_modules/usb/src/binding --napi_version=3 --node_abi_napi=napi' (1)
  CC(target) Release/obj.target/libusb/libusb/libusb/hotplug.o
  CC(target) Release/obj.target/libusb/libusb/libusb/io.o
  CC(target) Release/obj.target/libusb/libusb/libusb/strerror.o
  CC(target) Release/obj.target/libusb/libusb/libusb/sync.o
  CC(target) Release/obj.target/libusb/libusb/libusb/os/poll_posix.o
  CC(target) Release/obj.target/libusb/libusb/libusb/os/threads_posix.o
  CC(target) Release/obj.target/libusb/libusb/libusb/os/darwin_usb.o
  LIBTOOL-STATIC Release/usb.a
  CXX(target) Release/obj.target/usb_bindings/src/node_usb.o
  CXX(target) Release/obj.target/usb_bindings/src/device.o
  CXX(target) Release/obj.target/usb_bindings/src/transfer.o
  SOLINK_MODULE(target) Release/usb_bindings.node
  COPY /Users/user/myapp/app/node_modules/usb/src/binding/usb_bindings.node
  TOUCH Release/obj.target/action_after_build.stamp

Error output:
../src/node_printer_posix.cc:261:39: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
                v8::String::Utf8Value keyStr(key->ToString());
                                      ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/node_printer_posix.cc:262:39: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
                v8::String::Utf8Value valStr(iV8Options->Get(key)->ToString());
                                      ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/node_printer_posix.cc:321:39: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    REQUIRE_ARGUMENT_STRING(iArgs, 0, printername);
                                      ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/node_printer_posix.cc:344:39: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    REQUIRE_ARGUMENT_STRING(iArgs, 0, printername);
                                      ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/node_printer_posix.cc:367:39: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    REQUIRE_ARGUMENT_STRING(iArgs, 0, printername);
                                      ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/node_printer_posix.cc:403:39: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    REQUIRE_ARGUMENT_STRING(iArgs, 0, printername);
                                      ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/node_printer_posix.cc:405:39: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    REQUIRE_ARGUMENT_STRING(iArgs, 2, jobCommandV8);
                                      ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/node_printer_posix.cc:462:39: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    REQUIRE_ARGUMENT_STRING(iArgs, 1, printername);
                                      ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/node_printer_posix.cc:463:39: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    REQUIRE_ARGUMENT_STRING(iArgs, 2, docname);
                                      ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/node_printer_posix.cc:464:39: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    REQUIRE_ARGUMENT_STRING(iArgs, 3, type);
                                      ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/node_printer_posix.cc:509:39: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    REQUIRE_ARGUMENT_STRING(iArgs, 0, filename);
                                      ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/node_printer_posix.cc:510:39: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    REQUIRE_ARGUMENT_STRING(iArgs, 1, docname);
                                      ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/node_printer_posix.cc:511:39: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    REQUIRE_ARGUMENT_STRING(iArgs, 2, printer);
                                      ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
13 warnings generated.
../src/node_printer.cc:27:31: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
        v8::String::Utf8Value data_str_v8(iV8Value->ToString());
                              ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8.h:2819:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/user/.electron-gyp/iojs-3.0.0-nightly.20180821/deps/v8/include/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
1 warning generated.
node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(404): https://github.com/tessel/node-usb/releases/download/1.3.3/usb_bindings-v1.3.3-electron-v3.0-darwin-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for usb@1.3.3 and electron@3.0.0-nightly.20180821 (electron-v3.0 ABI, unknown) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Pre-built binaries not installable for usb@1.3.3 and electron@3.0.0-nightly.20180821 (electron-v3.0 ABI, unknown) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error Connection closed while downloading tarball file 
../libusb/libusb/core.c:../libusb/libusb/core.c:2241:35: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
2241:35: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
        if (header_len < 0 || header_len >= sizeof(buf)) {
                              ~~~~~~~~~~ ^  ~~~~~~~~~~~
../libusb/libusb/core.c:2250:44: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
        if (header_len < 0 || header_len >= sizeof(buf)) {
                              ~~~~~~~~~~ ^  ~~~~~~~~~~~
        if (text_len < 0 || text_len + header_len >= sizeof(buf)) {
                            ~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~
../libusb/libusb/core.c:2250:44: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
        if (text_len < 0 || text_len + header_len >= sizeof(buf)) {
                            ~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~
2 warnings generated.
2 warnings generated.
rm: ./Release/.deps/Release/obj.target/libusb/libusb/libusb/core.o.d.raw: No such file or directory
make: *** [Release/obj.target/libusb/libusb/libusb/core.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 ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/Cellar/node/10.7.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/user/myapp/app/node_modules/usb/src/binding/usb_bindings.node" "--module_name=usb_bindings" "--module_path=/Users/user/myapp/app/node_modules/usb/src/binding" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /Users/user/myapp/app/node_modules/usb
gyp ERR! node -v v10.7.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/10.7.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/user/myapp/app/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/Users/user/myapp/app/node_modules/usb/src/binding --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/user/myapp/app/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:961:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
node-pre-gyp ERR! System Darwin 17.7.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/10.7.0/bin/node" "/Users/user/myapp/app/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/user/myapp/app/node_modules/usb
node-pre-gyp ERR! node -v v10.7.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! usb@1.3.3 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the usb@1.3.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

6reactions
semiregcommented, Sep 4, 2018

I think I have fixed this… but unsure what the root cause is. My troubleshooting steps are documented below for the “future me” as well as “the next dev.”

Short answer, update top-level package.json with:

    "buildDependenciesFromSource": true,
    "nodeGypRebuild": false,
    "npmRebuild": false,

I used DEBUG=electron-builder at the command line and found that it was spawning a command:

  • rebuilding native production dependencies platform=darwin arch=x64
  • spawning        command=npm rebuild canvas@1.6.11 font-manager@0.3.0 printer@0.2.2 usb@1.3.3 cwd=/Users/user/myapp/app

However, this command worked in isolation, nothing new there… but then I noticed loaded configuration file=package.json ("build" field) and decided to RTFM.

I found these interesting options:

  • buildDependenciesFromSource = false Boolean - Whether to build the application native dependencies from source.
  • nodeGypRebuild = false Boolean - Whether to execute node-gyp rebuild before starting to package the app.
  • npmRebuild = true Boolean - Whether to rebuild native dependencies before starting to package the app.

In effect, enabling buildDependenciesFromSource and disabling npmRebuild fixed the issue. I’m going to leave this ticket open for a week to see if anyone else can weigh in on what is happening.

1reaction
aKaigegecommented, Sep 30, 2018

i just downgrade node.js to 8.x and it successfully! mapbox/node-pre-gyp#391

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix broken 'node-gyp' issue for Mac OS - Medium
This issue is usually caused because a node-gyp config file called common.gypi is not set up for your current Mac OS version. It...
Read more >
node-gyp serialport build error on Raspberry Pi 4
I have tried Node 12, 14, & 16; serialport 9 & 10...? I get the following error when doing npm i : >...
Read more >
LabJack-nodejs - npm
Currently, installers are available for Windows, Mac OS X, ... Ability to build native modules, for Windows this requires Visual Studio.
Read more >
Native Node Modules | Electron
Native Node.js modules are supported by Electron, but since Electron has a different application ... Tell node-pre-gyp to build module from source code....
Read more >
node-hid - npm.io
node-hid - Access USB HID devices from Node.js. npm build ... "node-gyp configure" configure makefiles npm run gypbuild # "node-gyp build" build native...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found