Automattic / Automattic/node-canvas

node-gyp failed to rebuild

Open
#2,267 6 comments 3 reactions 0 assignees View on GitHub
Installation help
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

## Issue or Feature
- [x] If this is an issue with installation, I have read the [troubleshooting guide](https://github.com/Automattic/node-canvas/issues/1511).

I can't build an Electron app as soon as I install `pdfjs-dist` (and by extension `canvas`). I'm not even importing nor using `pdfjs-dist`. The app can't compile and crashes immediately.

I have installed all the necessary packages with `brew`: `pkg-config`, `cairo`, `pango`, `libpng`, `jpeg`, `giflib`, `librsvg`, `libffi`.

The error is:

```js
> 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/canvas'
◼ Running generateAssets hook

› 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:60:14: warning: private field 'backend' is not used
Backend* backend;
^
1 warning generated.
CXX(target) Release/obj.target/canvas/src/backend/ImageBackend.o
CXX(target) Release/obj.target/canvas/src/backend/PdfBackend.o
In file included from ../src/backend/PdfBackend.cc:1:
In file included from ../src/backend/PdfBackend.h:4:
In file included from ../src/backend/../closure.h:5:
../src/backend/../Canvas.h:9:10: fatal error: 'pango/pangocairo.h' file not…
#include
^~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/canvas/src/backend/PdfBackend.o] Error 1
Error: `make` failed with exit code: 2
at ChildProcess.onExit (/Users/myname/Desktop/myapp/node_modu…
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. (/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)
```

## Environment
* Version of node-canvas (output of `npm list canvas`):
* └─┬ pdfjs-dist@3.4.120
└── canvas@2.11.2
* Environment
* node 18.16.1 on Mac OS X 13.4.1 Ventura, Intel 7, no M1/M2)

I have opened an [issue](https://github.com/mozilla/pdf.js/issues/16670) on pdfjs's repository.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.