Automattic / Automattic/node-canvas

Cannot install canvas on apple silicon

Open
#2,365 14 comments 0 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 have done: `brew install pkg-config cairo pango libpng jpeg giflib librsvg`

And I have tried many, many other ways to get around this (some of which are listed [here](https://github.com/HSF/phoenix/issues/627))

But I still cannot install canvas on Apple silicon. Failure is:
```
In file included from /Users/emoyse/Library/Caches/node-gyp/21.7.1/include/node/v8-array-buffer.h:12:
/Users/emoyse/Library/Caches/node-gyp/21.7.1/include/node/v8-local-handle.h:253:5: error: static assertion failed due to requirement 'std::is_base_of::value': type check
static_assert(std::is_base_of::value, "type check");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan_callbacks_12_inl.h:175:20: note: in instantiation of function template specialization 'v8::Local::Local' requested here
cbinfo(info, obj->GetInternalField(kDataIndex));
^
```

N.B. we don't actually have a direct dependency on canvas from [phoenix](https://github.com/HSF/phoenix), but get it from a package we use [jsroot](https://github.com/root-project/jsroot/).

```
emoyse@macminim1umass phoenix % yarn why canvas
└─ jsroot@npm:7.6.0
└─ canvas@npm:2.11.2 (via npm:^2.11.2)
```

## Steps to Reproduce
```
git clone https://github.com/HSF/phoenix.git
cd phoenix
yarn install
```

This will fail with:
```
➤ YN0009: │ canvas@npm:2.11.2 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/j6/cv3xx2910nx_pg7v2t8czqzc0000gn/T/xfs-bf1ea463/build.log)
```
(build.log is attached)

What is weird is checking out node-canvas and doing `yarn install` there seems to work... the only obvious difference I see in the log files is `node-gyp` version:
```
< gyp info using node-gyp@10.0.1
---
> gyp info using node-gyp@9.3.1
```

## Your Environment
* yarn --version : 3.3.1
* Version of node-canvas: v2.11.2
* Environment: node 21.7.1 on macOS 14.3.1, Apple M1

---
[build.log](https://github.com/Automattic/node-canvas/files/14652322/build.log)

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.