forge icon indicating copy to clipboard operation
forge copied to clipboard

node-gyp failed to rebuild

Open DoneDeal0 opened this issue 1 year ago • 7 comments

Pre-flight checklist

  • [X] I have read the contribution documentation for this project.
  • [X] I agree to follow the code of conduct that this project uses.
  • [X] I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

6.2.1

Electron version

25.2.0

Operating system

macOS 13.4.1

Last known working Electron Forge version

No response

Expected behavior

The app should compile.

Actual behavior

The electron app doesn't compile properly. Here is the complete log:

> electron-forge start

✔ Checking your system
✔ Locating application
✔ Loading configuration
✖ Preparing native dependencies: 0 / 1
  › node-gyp failed to rebuild '/Users/myname/Desktop/myapp/node_modules/ca…
◼ Running generateAssets hook

› Package 'gobject-2.0' requires 'libffi >= 3.0.0' but version of libffi is 2.1
  Package 'gobject-2.0' requires 'libffi >= 3.0.0' but version of libffi is 2.1
  SOLINK_MODULE(target) Release/canvas-postbuild.node
  CXX(target) Release/obj.target/canvas/src/backend/Backend.o
  In file included from ../src/backend/Backend.cc:1:
  ../src/backend/Backend.h:3:10: fatal error: 'cairo.h' file not found
  #include <cairo.h>
  ^~~~~~~~~
  1 error generated.
  make: *** [Release/obj.target/canvas/src/backend/Backend.o] Error 1
  Error: `make` failed with exit code: 2
  at ChildProcess.onExit (/Users/myname/Desktop/myapp/node_modules/node-gyp…
  at ChildProcess.emit (node:events:513:28)
  at ChildProcess._handle.onexit (node:internal/child_process:291:12)

An unhandled rejection has occurred inside Forge:
Error: node-gyp failed to rebuild '/Users/myname/Desktop/myapp/node_modules/canvas'
at ChildProcess.<anonymous> (/Users/myname/Desktop/myapp/node_modules/@electron/rebuild/lib/module-type/node-gyp/node-gyp.js:118:24)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)

Steps to reproduce

I have the latest version of Electron and associated lib. The app works fine on macOS Big Sure, but not on macOS Ventura.

Do I need to globally install a package like node-gyp to make it work?

Additional information

No response

DoneDeal0 avatar Jul 07 '23 20:07 DoneDeal0

@DoneDeal0 Sorry for the delayed response. Do you have an exact repro available? This seems like an issue with the native module you're using but I'd like to confirm the setup on my end as well.

erickzhao avatar Aug 03 '23 22:08 erickzhao

@erickzhao here is a basic repo: https://github.com/DoneDeal0/electron-build-fail

If I remove it, the build works fine. Unfortunately, I need this lib.

I have node 18.16.1. The build fails on a machine with an I7 chip, but works fine on an M2 machine. This is very strange. The PDFJS team won't help me because I use their lib in Electron.

DoneDeal0 avatar Aug 05 '23 12:08 DoneDeal0

@erickzhao hi, have you had time to research this issue?

DoneDeal0 avatar Aug 16 '23 20:08 DoneDeal0

i have a Similar question

electron-forge make

✔ Checking your system rget/fse/fsevents.o In file included from ../fsevents.cc:6: ../../../../nan/nan.h:688:39: warning: 'IdleNotificationDeadline' is deprecated: Use… return v8::Isolate::GetCurrent()->IdleNotificationDeadline( ^ /Users/tangsong/.electron-gyp/28.1.4/include/node/v8-isolate.h:1343:3: note: 'IdleNo… V8_DEPRECATE_SOON( ^ /Users/tangsong/.electron-gyp/28.1.4/include/node/v8config.h:561:41: note: expanded …

define V8_DEPRECATE_SOON(message) [[deprecated(message)]]

^ ../fsevents.cc:14:10: fatal error: 'src/storage.cc' file not found #include "src/storage.cc" ^~~~~~~~~~~~~~~~ 1 warning and 1 error generated. make: *** [Release/obj.target/fse/fsevents.o] Error 1 Error: make failed with exit code: 2 at ChildProcess.onExit (/Users/tangsong/Documents/cqq/test/demo/node_modules/node-gy… at ChildProcess.emit (node:events:513:28) at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)

An unhandled rejection has occurred inside Forge: Error: node-gyp failed to rebuild '/private/var/folders/6c/44_3vj9n74sdtr04s4nndkr40000gp/T/electron-packager/tmp-JTs2GE/Electron.app/Contents/Resources/app/node_modules/watchpack-chokidar2/node_modules/fsevents' at ChildProcess. (/Users/tangsong/Documents/cqq/test/demo/node_modules/@electron/rebuild/lib/module-type/node-gyp/node-gyp.js:118:24) at ChildProcess.emit (node:events:513:28) at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)

cqtangsong avatar Jan 22 '24 10:01 cqtangsong

Same problem for me when I installed ssh2 in my electron forge project. Node-gyp can not rebuild cpu-features which is one of the dependencies of ssh2. The environment info is: cpu: M1 Pro os: MacOS 14.3.1 node: v18.18.0 electron: ^29.0.1 electron-forge: ^7.3.0 ssh2: ^1.15.0

Brown000 avatar Feb 26 '24 07:02 Brown000

Same problem for me when I installed ssh2 in my electron forge project. Node-gyp can not rebuild cpu-features which is one of the dependencies of ssh2. The environment info is: cpu: M1 Pro os: MacOS 14.3.1 node: v18.18.0 electron: ^29.0.1 electron-forge: ^7.3.0 ssh2: ^1.15.0

For this problem, I found ssh2-electron-no-cpu-features which do not need cpu-features dependency. And this worked for me. If you using typescript, you can just install @types/ssh2 and rename node_modules/@types/ssh2 to ssh2-electron-no-cpu-features, then you can have fully annotations. Wish this can help you if you have same problem.

Brown000 avatar Feb 26 '24 10:02 Brown000