Need help getting node-canvas installed with on an M1 mac. Here is the log.
yarn install
...
➤ YN0000: ┌ Link step
➤ YN0007: │ canvas@npm:2.10.1 must be built because it never has been before or the last one failed
➤ YN0009: │ canvas@npm:2.10.1 couldn't be built successfully (exit code 1, logs can be found here: /private/tmp/xfs-97e0a91f/build.log)
➤ YN0000: └ Completed in 14s 140ms
➤ YN0000: Failed with errors in 14s 708ms
# This file contains the result of Yarn building a package (canvas@npm:2.10.1)
# Script name: install
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | darwin | arm64
node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.10.1/canvas-v2.10.1-node-v108-darwin-unknown-arm64.tar.gz
node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.10.1/canvas-v2.10.1-node-v108-darwin-unknown-arm64.tar.gz
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v108 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.10.1/canvas-v2.10.1-node-v108-darwin-unknown-arm64.tar.gz
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp info ok
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp info find Python using Python version 3.10.8 found at "/opt/homebrew/opt/[email protected]/bin/python3.10"
gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.10
gyp info spawn args [
gyp info spawn args '/Users/m1macuser/Code/projectfolder/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/m1macuser/Code/projectfolder/node_modules/canvas/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/m1macuser/Code/projectfolder/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/m1macuser/Library/Caches/node-gyp/18.9.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=/Users/m1macuser/Library/Caches/node-gyp/18.9.1',
gyp info spawn args '-Dnode_gyp_dir=/Users/m1macuser/Code/projectfolder/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/m1macuser/Library/Caches/node-gyp/18.9.1/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/m1macuser/Code/projectfolder/node_modules/canvas',
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 ok
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/Users/m1macuser/Code/projectfolder/node_modules/canvas/build'
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 [-Wunused-private-field]
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
CXX(target) Release/obj.target/canvas/src/backend/SvgBackend.o
CXX(target) Release/obj.target/canvas/src/bmp/BMPParser.o
CXX(target) Release/obj.target/canvas/src/Backends.o
CXX(target) Release/obj.target/canvas/src/Canvas.o
In file included from ../src/Canvas.cc:21:
../src/Util.h:18:7: warning: 'SetAccessor' is deprecated [-Wdeprecated-declarations]
Nan::SetAccessor(
^
../../nan/nan.h:2512:1: note: 'SetAccessor' has been explicitly marked deprecated here
NAN_DEPRECATED inline void SetAccessor(
^
../../nan/nan.h:110:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
^
1 warning generated.
CXX(target) Release/obj.target/canvas/src/CanvasGradient.o
CXX(target) Release/obj.target/canvas/src/CanvasPattern.o
CXX(target) Release/obj.target/canvas/src/CanvasRenderingContext2d.o
In file included from ../src/CanvasRenderingContext2d.cc:19:
../src/Util.h:18:7: warning: 'SetAccessor' is deprecated [-Wdeprecated-declarations]
Nan::SetAccessor(
^
../../nan/nan.h:2512:1: note: 'SetAccessor' has been explicitly marked deprecated here
NAN_DEPRECATED inline void SetAccessor(
^
../../nan/nan.h:110:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
^
1 warning generated.
CXX(target) Release/obj.target/canvas/src/closure.o
CXX(target) Release/obj.target/canvas/src/color.o
CXX(target) Release/obj.target/canvas/src/Image.o
In file included from ../src/Image.cc:11:
../src/Util.h:18:7: warning: 'SetAccessor' is deprecated [-Wdeprecated-declarations]
Nan::SetAccessor(
^
../../nan/nan.h:2512:1: note: 'SetAccessor' has been explicitly marked deprecated here
NAN_DEPRECATED inline void SetAccessor(
^
../../nan/nan.h:110:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
^
../src/Image.cc:1164:3: warning: 'rsvg_handle_get_dimensions' is deprecated: Use 'rsvg_handle_get_intrinsic_size_in_pixels' instead [-Wdeprecated-declarations]
rsvg_handle_get_dimensions(_rsvg, dims);
^
/nix/store/5b64vfc6bhip3xwqg3nvb8bv80wn5rf4-librsvg-2.55.1-dev/include/librsvg-2.0/librsvg/rsvg.h:705:1: note: 'rsvg_handle_get_dimensions' has been explicitly marked deprecated here
RSVG_DEPRECATED_FOR(rsvg_handle_get_intrinsic_size_in_pixels)
^
/nix/store/5b64vfc6bhip3xwqg3nvb8bv80wn5rf4-librsvg-2.55.1-dev/include/librsvg-2.0/librsvg/rsvg.h:50:32: note: expanded from macro 'RSVG_DEPRECATED_FOR'
#define RSVG_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) RSVG_API
^
/nix/store/dp31bsk70zdyh46jpxzjwasbqlv2ncgv-glib-2.74.0-dev/include/glib-2.0/glib/gmacros.h:1211:44: note: expanded from macro 'G_DEPRECATED_FOR'
#define G_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
^
../src/Image.cc:1203:24: warning: 'rsvg_handle_render_cairo' is deprecated: Use 'rsvg_handle_render_document' instead [-Wdeprecated-declarations]
gboolean render_ok = rsvg_handle_render_cairo(_rsvg, cr);
^
/nix/store/5b64vfc6bhip3xwqg3nvb8bv80wn5rf4-librsvg-2.55.1-dev/include/librsvg-2.0/librsvg/rsvg-cairo.h:87:1: note: 'rsvg_handle_render_cairo' has been explicitly marked deprecated here
RSVG_DEPRECATED_FOR(rsvg_handle_render_document)
^
/nix/store/5b64vfc6bhip3xwqg3nvb8bv80wn5rf4-librsvg-2.55.1-dev/include/librsvg-2.0/librsvg/rsvg.h:50:32: note: expanded from macro 'RSVG_DEPRECATED_FOR'
#define RSVG_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) RSVG_API
^
/nix/store/dp31bsk70zdyh46jpxzjwasbqlv2ncgv-glib-2.74.0-dev/include/glib-2.0/glib/gmacros.h:1211:44: note: expanded from macro 'G_DEPRECATED_FOR'
#define G_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
^
3 warnings generated.
CXX(target) Release/obj.target/canvas/src/ImageData.o
In file included from ../src/ImageData.cc:5:
../src/Util.h:18:7: warning: 'SetAccessor' is deprecated [-Wdeprecated-declarations]
Nan::SetAccessor(
^
../../nan/nan.h:2512:1: note: 'SetAccessor' has been explicitly marked deprecated here
NAN_DEPRECATED inline void SetAccessor(
^
../../nan/nan.h:110:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
^
1 warning generated.
CXX(target) Release/obj.target/canvas/src/init.o
CXX(target) Release/obj.target/canvas/src/register_font.o
../src/register_font.cc:9:10: fatal error: 'CoreText/CoreText.h' file not found
#include <CoreText/CoreText.h>
^~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [canvas.target.mk:176: Release/obj.target/canvas/src/register_font.o] Error 1
make: Leaving directory '/Users/m1macuser/Code/projectfolder/node_modules/canvas/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/m1macuser/Code/projectfolder/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack at ChildProcess.emit (node:events:513:28)
gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Darwin 21.6.0
gyp ERR! command "/nix/store/5y4bd2r99zhdbir95w5pf51bwfg37bwa-nodejs-18.9.1/bin/node" "/Users/m1macuser/Code/projectfolder/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--update-binary" "--module=/Users/m1macuser/Code/projectfolder/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/Users/m1macuser/Code/projectfolder/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v108"
gyp ERR! cwd /Users/m1macuser/Code/projectfolder/node_modules/canvas
gyp ERR! node -v v18.9.1
gyp ERR! node-gyp -v v9.3.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/nix/store/5y4bd2r99zhdbir95w5pf51bwfg37bwa-nodejs-18.9.1/bin/node /Users/m1macuser/Code/projectfolder/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --update-binary --module=/Users/m1macuser/Code/projectfolder/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/Users/m1macuser/Code/projectfolder/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/Users/m1macuser/Code/projectfolder/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
node-pre-gyp ERR! stack at ChildProcess.emit (node:events:513:28)
node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1091:16)
node-pre-gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:302:5)
node-pre-gyp ERR! System Darwin 21.6.0
node-pre-gyp ERR! command "/nix/store/5y4bd2r99zhdbir95w5pf51bwfg37bwa-nodejs-18.9.1/bin/node" "/Users/m1macuser/Code/projectfolder/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
node-pre-gyp ERR! cwd /Users/m1macuser/Code/projectfolder/node_modules/canvas
node-pre-gyp ERR! node -v v18.9.1
node-pre-gyp ERR! node-pre-gyp -v v1.0.10
node-pre-gyp ERR! not ok
Failed to execute '/nix/store/5y4bd2r99zhdbir95w5pf51bwfg37bwa-nodejs-18.9.1/bin/node /Users/m1macuser/Code/projectfolder/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --update-binary --module=/Users/m1macuser/Code/projectfolder/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/Users/m1macuser/Code/projectfolder/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
This seems to throw the error:
1 warning generated.
CXX(target) Release/obj.target/canvas/src/init.o
CXX(target) Release/obj.target/canvas/src/register_font.o
../src/register_font.cc:9:10: fatal error: 'CoreText/CoreText.h' file not found
#include <CoreText/CoreText.h>
I'm stuck. Please help!
Other notes:
- OSX 12.6
- Node v.18 (installed with nix)
- Xcode and Xcode-select installed
- Nix used to install other lib deps (as you can see in the logs)
Node build:
file node_modules/canvas/build/Release/canvas-postbuild.node
node_modules/canvas/build/Release/canvas-postbuild.node: Mach-O 64-bit arm64 bundle, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL>
Nix shell:
# { pkgs ? import <nixpkgs> {} }:
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "myproject";
nativeBuildInputs = [ pkg-config ];
buildInputs = [
nodejs-18_x
yarn
jdk
docker
chromedriver
docker
rustup
libuuid
act
cairo
pango
pkg-config
nodePackages.node-gyp
libpng
llvm
librsvg
pixman
giflib
libjpeg
];
# APPEND_LIBRARY_PATH = "${lib.makeLibraryPath [ libGL libuuid google-chrome-dev]}";
# shellHook = ''
# LD=$CC
# export LD_LIBRARY_PATH="$APPEND_LIBRARY_PATH:$LD_LIBRARY_PATH"
# '';
}